SLIDE 18 Timer with OC-Match Interrupt, non-blocking ISR
. equ temp , 0x10 . s e c t i o n . t e x t . g l o b a l main . org 0x0000 rjmp main . org OC0Aaddr∗2 rjmp
main : ; i n i t i a l i z e st ack p o i n t e r l d i temp , l o8 (RAMEND)
SPL , temp l d i temp , hi8 (RAMEND)
SPH, temp ; setup PORTA l d i temp , 0xFF
DDRA, temp
PORTA, temp ; c o n f i g u r e timer l d i temp , (1<< WGM01)
TCCR0A, temp l d i temp , 0x27
OCR0A, temp l d i temp , 0x00
TCNT0, temp l d i temp , (1<<OCIE0A) s t s TIMSK0 , temp ; s t a r t c l o c k l d i temp , (1<<CS01)
TCCR0B, temp s e i i n f i n i t e l o o p : rjmp i n f i n i t e l o o p
i n temp , PORTA i n c temp
PORTA, temp brne n o o v e r f l o w s e i ; SC
l d i r18 , 255 l o o p e r s : dec r19 brne l o o p e r s n o o v e r f l o w : r e t i March 13, 2017 52
Timer with OC-Interrupt, non-blocking ISR
Observation
Behaviour as specified. Do we need the infinity loop?
March 13, 2017 53
Timer with OC-Interrupt, non-blocking ISR, and sleep mode
. s e c t i o n . t e x t . g l o b a l main . org 0x0000 rjmp main . org OC0Aaddr∗2 rjmp
main : ; i n i t i a l i z e st ack p o i n t e r l d i temp , l o8 (RAMEND)
SPL , temp l d i temp , hi8 (RAMEND)
SPH, temp ; setup PORTA l d i temp , 0xFF
DDRA, temp
PORTA, temp ; c o n f i g u r e timer l d i temp , (1<< WGM01)
TCCR0A, temp l d i temp , 0x27
OCR0A, temp l d i temp , 0x00
TCNT0, temp l d i temp , (1<<OCIE0A) s t s TIMSK0 , temp ; s t a r t c l o c k l d i temp , (1<<CS01)
TCCR0B, temp s e i i n f i n i t e l o o p : ; goto s l e e p c l i l d i temp , (1<<SE)
temp s e i s l e e p rjmp i n f i n i t e l o o p
i n temp , PORTA i n c temp
PORTA, temp brne n o o v e r f l o w s e i ; SC
l d i r18 , 255 l o o p e r s : dec r19 brne l o o p e r s n o o v e r f l o w : r e t i March 13, 2017 54