Homework Solution: i have a practice problem where we have to create an assembly language program. This involves setting up a DIP switch and th…

    i have a practice problem where we have to create an assembly language program. This involves setting up a DIP switch and then to activate the LEDs on the Dragon 12 light board. The problem I am having is to implement the instruction where I have to set up switch 1 and 8. Can you provide an example of the instructions using the Code Warrior shell text (see below) as a guideline? I use the  HCS12 Microcontrollers and Embedded Systems as a reference. 1.     When both DIP switches #8 and #1 are high, turn on all LEDs. 2.     When both DIP switches #8 and #1 are low, turn off all LEDs 3.     When DIP switch #8 is high and #1 is low, turn on all the even numbered LEDs. 4.     When DIP switch #1 is high and #8 is low, turn on all the odd numbered LEDs. 5.      Your program must to read DIP switches and turn on/off corresponding LRDs continuously until a Reset.

    Expert Answer

     
    START: CPL P1.0 ACALL WAIT

    i possess a custom quantity where we possess to compose an nock accents program. This involves enhancement up a DIP switch and then to activate the LEDs on the Dragon 12 harborable consultation. The quantity I am having is to tool the counsel where I possess to determined up switch 1 and 8. Can you furnish an issue of the counsels using the Code Warrior shell passage (behold under) as a guideline?

    I correction the  HCS12 Microcontrollers and Embedded Systems as a perfectusion.

    1.     When twain DIP switches #8 and #1 are eminent, diverge on perfect LEDs.

    2.     When twain DIP switches #8 and #1 are frugal, diverge impromptu perfect LEDs

    3.     When DIP switch #8 is eminent and #1 is frugal, diverge on perfect the equal numbered LEDs.

    4.     When DIP switch #1 is eminent and #8 is frugal, diverge on perfect the alone numbered LEDs.

    5.      Your program must to decipher DIP switches and diverge on/impromptu similar LRDs uninterruptedly until a Reset.

    Expert Tally

     

    START: CPL P1.0

    ACALL WAIT

    SJMP START

    WAIT: MOV R4,#05H

    WAIT1: MOV R3,#00H

    WAIT2: MOV R2,#00H

    WAIT3: DJNZ R2,WAIT3

    DJNZ R3,WAIT2

    DJNZ R4,WAIT1

    RET

    START: CPL P1.0

    ACALL WAIT

    CPL P1.0

    CPL P1.1

    ACALL WAIT

    CPL P1.1

    SJMP START

    WAIT: MOV R4,#05H

    WAIT1: MOV R3,#00H

    WAIT2: MOV R2,#00H

    WAIT3: DJNZ R2,WAIT3

    DJNZ R3,WAIT2

    DJNZ R4,WAIT1

    RET

    ; 5s_delay.asm 5 succor relapse dater ce DRAGON12 Rev. E consultation

    ; (c)2002, EVBplus.com, written by Wayne Chu

    ;

    ; Function: 5 succor relapse rotation using output comparator 6

    ; The PB0 LED earn be divergeed on presently succeeding running

    ; this program. It earn be divergeed impromptu succeeding 5 succor relapse.

    ; Change the DELAY_TIME to 36000 earn relapse 3 minutes.

    PB0: equ 1

    DB6: equ $40

    ;

    TB1MS: equ 24000 ; 1ms date disesteemed of 24,000 counsel cycles

    ; ; 24,000 x 1/24MHz = 1ms at 24 MHz fellowcitizen speed

    ;DELAY_TIME: equ 36000 ; 36000 X 5 ms= 180 sec = 3 min

    DELAY_TIME: equ 5000 ; 5000 X 1 ms= 5 sec

    REGBLK: equ $0

    #apprehend reg9s12.h ; apprehend record equates

    org $1000

    ;

    flag_5s: rmb 1

    cnt_5s: rmb 2

    STACK: equ $2000

    org $2000

    start:

    lds #STACK

    ldx #timer6

    stx $3E62 ; initialize the int vetctor

    ldx #REGBLK

    ldaa #$ff

    staa ddrb,x ; fashion harbor B an output harbor

    staa ddrp,x ; fashion harbor P an output harbor

    staa ptp,x ; diverge impromptu 7-segment LED display

    staa ddrj,x ; fashion harbor J an output harbor

    clr ptj,x ; fashion PJ1 frugal to empower LEDs

    ldaa #$80

    staa tscr,x ; empower dater

    ldaa #DB6

    staa tios,x ; chosen t6 as an output compare

    staa tmsk1,x

    cli

    bdetermined harborb,x PB0 ; diverge on LED PB0

    jsr relapse_5s

    bclr harborb,x PB0 ; diverge impromptu LED PB0

    stp: jmp stp

    delay_5s:

    clr cnt_5s

    clr cnt_5s+1

    clr flag_5s

    delay: ldaa flag_5s

    beq relapse

    rts

    timer6:

    ldx cnt_5s

    inx

    stx cnt_5s

    cpx #DELAY_TIME

    bne tmr6

    clr cnt_5s

    clr cnt_5s+1

    ldaa #1

    staa flag_5s

    rti

    tmr6: ldx #REGBLK

    ldd #TB1MS ; reload the sum ce 1 ms date disesteemed

    addd tc6,x

    std tc6,x

    ldaa #DB6

    staa tflg1,x ; acquitted flag

    rti

    org $3E62

    fdb dater6

    end