in detail explain each line of this code and how it works.     #include        Reg9S12.h UserTimerCh5    equ     $3E64 hi_freq         equ     1500                    ;delay count for 1000 Hz with 1:8  precaler lo_freq         equ     5000                    ;delay count for 300 Hz with 1:8 prescaler                 org     $1500 delay           ds.w    1                       ;store the delay for output-compare                 org     $2000                 lds     #$2000                 movw    #OC5_isr,UserTimerCh5   ;initialize the interrupt vector entry                 movb    #$90,TSCR1              ;enable TCNT, fast timer flage clear                 movb    #$03,TSCR2              ;set main timer prescaler to 8                 bset    TIOS,#$20               ;enable Ch.5 for output compare                 movb    #$04,TCTL1                ;select toggle for OC5 pin action(OM5:OL5=01)                 ldd     #hi_freq                 ;use high frequency delay count first                 std     delay                   ;bw use high-frequency delay count first                 ldd     TCNT                    ;start the high frequency sound                 addd    delay                 std     TC5                 bset    TIE,#$20                ;enable OC5 interrupt (TIE is equivalent to TMSK1 in REG9S12.h)                 cli                             ;enables i-bit interrupts forever         ldy     #50                    ;wait for 1 second                 jsr     delay10ms                 movb    #$00, TCTL1             ; clear all channels                 ldy     #50                     ; hold it for 0.5 channel                 jsr     delay10ms                 movb    #$04, TCTL1             ;open up channel 5                 movw    #lo_freq,delay          ;switch to low-frequency delay count                 ldy     #100                    ;wait for 0.5 second                 jsr     delay10ms                 movb    #$00, TCTL1             ; clear all channels                 ldy     #50                 jsr     delay10ms                 movb    #$04, TCTL1                 movw    #hi_freq,delay          ;switch to high-frequency delay count                 bra     forever OC5_isr         ldd     TC5                 addd    delay                 std     TC5                 rti ;*************************************************** ;The following subroutine creates a time delay that ;is equal to [y] x 10 ms. The timer prescaler is 1:8 ;*************************************************** delay10ms       pshd                            ;save Accumulator D                 bset    TIOS,#$01               ;enable OC0                 ldd     TCNT again1          addd    #30000                  ;start an output compare operation                 std     TC0                     ;with 10 ms time delay                 brclr   TFLG1,#$01,*                 ldd     TC0                 dbne    y,again1                 bclr    TIOS,#$01               ;disable OC0                 puld                            ;restore Accumulator D                 rts                 end

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

in detail explain each line of this code and how it works.

 

 

#include        Reg9S12.h

UserTimerCh5    equ     $3E64
hi_freq         equ     1500                    ;delay count for 1000 Hz with 1:8  precaler
lo_freq         equ     5000                    ;delay count for 300 Hz with 1:8 prescaler
                org     $1500
delay           ds.w    1                       ;store the delay for output-compare
                org     $2000
                lds     #$2000
                movw    #OC5_isr,UserTimerCh5   ;initialize the interrupt vector entry
                movb    #$90,TSCR1              ;enable TCNT, fast timer flage clear
                movb    #$03,TSCR2              ;set main timer prescaler to 8
                bset    TIOS,#$20               ;enable Ch.5 for output compare
                movb    #$04,TCTL1                ;select toggle for OC5 pin action(OM5:OL5=01)
                ldd     #hi_freq                 ;use high frequency delay count first
                std     delay                   ;bw use high-frequency delay count first
                ldd     TCNT                    ;start the high frequency sound
                addd    delay
                std     TC5
                bset    TIE,#$20                ;enable OC5 interrupt (TIE is equivalent to TMSK1 in REG9S12.h)
                cli                             ;enables i-bit interrupts
forever         ldy     #50                    ;wait for 1 second
                jsr     delay10ms
                movb    #$00, TCTL1             ; clear all channels
                ldy     #50                     ; hold it for 0.5 channel
                jsr     delay10ms
                movb    #$04, TCTL1             ;open up channel 5
                movw    #lo_freq,delay          ;switch to low-frequency delay count
                ldy     #100                    ;wait for 0.5 second
                jsr     delay10ms
                movb    #$00, TCTL1             ; clear all channels
                ldy     #50
                jsr     delay10ms
                movb    #$04, TCTL1
                movw    #hi_freq,delay          ;switch to high-frequency delay count
                bra     forever
OC5_isr         ldd     TC5
                addd    delay
                std     TC5
                rti
;***************************************************
;The following subroutine creates a time delay that
;is equal to [y] x 10 ms. The timer prescaler is 1:8
;***************************************************
delay10ms       pshd                            ;save Accumulator D
                bset    TIOS,#$01               ;enable OC0
                ldd     TCNT
again1          addd    #30000                  ;start an output compare operation
                std     TC0                     ;with 10 ms time delay
                brclr   TFLG1,#$01,*
                ldd     TC0
                dbne    y,again1
                bclr    TIOS,#$01               ;disable OC0
                puld                            ;restore Accumulator D
                rts
                end

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY