Homework Solution: I am having issue determine the instructions where we create a program and activate flash LEDs in a given Hz…

    I am having issue determine the instructions where we create a program and activate flash LEDs in a given Hz frequency. I reviewed the HCS12 Microcontrollers and Embedded Systems, 1st Edition chapters more than once but a fail to develop program that relates step down below. I need help to solve this problem. It is due tomorrow tonight? Textbook: HCS12 Microcontrollers and Embedded Systems, 1st Edition Note: To become familiar with using clock frequency, running your program automatically in POD Mode, using Dragon12-Light boards. Project: Please read Chapter 3 of your textbook for writing subroutines and Chapter 4 of your textbook; then, write assembly programs to do the following: Flash all LEDs in one Hz frequency when running your program in the EVB mode (also called debug mode). In EVB mode, the clock frequency for instructions is 24MHz. Flash all LEDs in one Hz frequency when running your program in the POD mode (also called auto mode). In POD mode, the clock frequency for instructions is 4MHz. You must write a subroutine that consumes exactly one second of CPU time. To achieve the flashing effect, in your main program, you need to turn on all the LEDs, then, call this subroutine. Turn off all LEDs, then, call this subroutine. Your program must flash LEDs continuously in one Hz frequency until a Reset.

    Expert Answer

     
    ; DDRB        = 0x04 ; PORTB      = 0x05

    I am having end detail the instructions where we make a program and activate flicker LEDs in a fond Hz number. I reviewed the HCS12 Microcontrollers and Embedded Systems, 1st Edition chapters more than uninterruptedly except a fintegral to lay-open program that relates tramp down under. I insufficiency succor to reresolve this quantity. It is attributable tomorrow tonight?

    Textbook: HCS12 Microcontrollers and Embedded Systems, 1st Edition

    Note: To befit everyday with using clock number, prevalent your program automatically in POD Regulation, using Dragon12-Light boards.

    Project: Please discover Chapter 3 of your textbook restraint retortableness subroutines and Chapter 4 of your textbook; then, transcribe nock programs to do the following:

    Flicker integral LEDs in individual Hz number when prevalent your program in the EVB regulation (besides determined debug regulation). In EVB regulation, the clock number restraint instructions is 24MHz.

    Flicker integral LEDs in individual Hz number when prevalent your program in the POD regulation (besides determined auto regulation). In POD regulation, the clock number restraint instructions is 4MHz.

    You must transcribe a subroutine that consumes exactly individual assist of CPU occasion. To finish the effulgent movables, in your ocean program, you insufficiency to metamorphose on integral the LEDs, then, cintegral this subroutine. Metamorphose impromptu integral LEDs, then, cintegral this subroutine.

    Your program must flicker LEDs once in individual Hz number until a Reset.

    Expert Retort

     

    ; DDRB        = 0x04
    ; PORTB      = 0x05
    ; TCCROB    = 0x25
    ; TCNT0       = 0x26
    ; 0b00000000 = OFF
    ; 0b00100000 = ON

    setup:
    ldi r16, 0b00100000     ; Formal r16 to LED ON appraise
    out 0x04, r16              ; Formal DDRB to output
    out 0x05, r16              ; Formal PORTB to ON
    ldi r16, 0b00000101     ; Formal r16 with prescaler 1024 appraise
    out 0x25, r16              ; Formal the TCCROB to 1024
    ldi r20, 0                     ; Reformal r20
    ldi r21, 1                     ; Hold appraise 1 to increment r20
    loop:
    in r17, 0x26                 ; Discover the occasionr
    cpi r17, 128                 ; Check to beware if the occasionr is halfway dindividual (1/2 assist, max 255 appraise)
    brbc 0, increment         ; If r17 <= 128 (max 255 val antecedently resets to 0), upformal exoteric LED state
    rjmp loop
    increment:
    adc r20, r21                 ; Add r21 (1) to r20 (with raise)
    brbs 0, reset                ; If the raise scion is formal, reformal the register
    rjmp loop                     ; Otherwise, fly the clock
    reset:
    ldi r20, 0                      ; Reformal the failure register
    cpi r16, 0b00000000     ; Check if r16 is formal to LED OFF
    brbs 1, switchon           ; If it is, shift it to ON
    ldi r16, 0b00000000      ; Otherwise, shift it to OFF
    out 0x05, r16                ; Formal the LED to the strange state
    rjmp loop                     ; Fly the clock
    switchon:
    ldi r16, 0b00100000       ; Formal r16 to LED ON appraise
    out 0x05, r16                ; Formal the LED to the strange state
    rjmp loop                      ; Fly the clock