1 / 11

Interrupt-Driven State Machine

Interrupt-Driven State Machine. Lecture L4.2a. State Machine with Delay. Use Real-time Interrupt with 50 ms Period. State Machine with Delay. Data Structure. $7B. ; LED state machine example ptp equ $258 ; Port P ddrp equ $25A ; Direction

aspen
Download Presentation

Interrupt-Driven State Machine

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Interrupt-DrivenState Machine Lecture L4.2a

  2. State Machine with Delay

  3. Use Real-time Interrupt with 50 ms Period

  4. State Machine with Delay

  5. Data Structure

  6. $7B

  7. ; LED state machine example ptp equ $258 ; Port P ddrp equ $25A ; Direction ptj equ $268 ; Port J ddrj equ $26A ; Direction rti_ivec equ $0FF2 crgflg equ $0037 crgint equ $0038 rtictl equ $003b Note: Should be $0FF0. Monitor error

  8. ORG $800 dtime db 1 num_states db 3 cur_state db 3 s0 db $80 ;red led s0t db 10 ;1/2 sec delay s1 db $40 ;yellow led s1t db 20 ;1 sec delay s2 db $20 ;green led s2t db 15 ;3/4 sec delay

  9. ORG $4000 main jsr portp_init jsr rti_init mn1 bra mn1 portp_init ldaa #$E0 ;PP7..PP5 outputs staa ddrp ldaa #0 staa ptp ;leds off rts rti_init sei ;disable interrupts ldaa #$7b staa rtictl ;set rti to 49.15 ms ldaa #$80 staa crgint ;enable r ldx #rti_intser stx rti_ivec ;store rti int vector cli ;enable interrupts rts

  10. rti_intser ldaa dtime deca ;dec dtime bne exit ;if not zero ldab cur_state cmpb num_states ; if cur_state = num_state bne ri1 clrb stab cur_state ; reset cur_state to 0 ri1 lslb ; ptr = cur_state * 2 ldx #s0 ; x -> state 0 abx ; x -> next state ldaa 0,x ; get state value staa ptp ; and display it inc cur_state ; update cur_state ldaa 1,x ; get delay time exit staa dtime ; and store it in dtime ldaa #$80 staa crgflg ;clear rti flag rti

  11. ORG $800 dtime db 1 num_states db 3 cur_state db 3 s0 db $80 ;red led s0t db 10 ;1/2 sec delay s1 db $40 ;yellow led s1t db 20 ;1 sec delay s2 db $20 ;green led s2t db 15 ;3/4 sec delay

More Related