Click here to load reader

AVR timer/counter

  • View
    100

  • Download
    11

Embed Size (px)

DESCRIPTION

AVR timer/counter

Text of AVR timer/counter

AVR STUDY 2

INTERRUPT? CPU / ISR = Interrupt Service Routine

?

1

?

delay

?

ATMEGA128 4 8 / 0,2 8 0x00 ~ 0xFF

TCNT, TCCR, OCR, ASSR, TIMSK, TIFR, SFIOR 0x0000 ~ 0xFFFF

16 / 1,3

16 TCNT, TCCRnA, TCCRnB, TCCRnC, OCRnA~OCRnC, ICR, TIMSK, ETIMSK, TIFR, ETIFR, SFIOR , CTC , Fast PWM MODE. PC PWM MOCE

8 /0 cli() sei() ISR(TIMER0_OVF_vect) TCCR0 TCNT0 TIMSK

cli() & sei() & ISR(TIMER0_OVF_vect) cli() = CLear Interrupt flag sei() = SEt Interrupt mask. ISR(TIMER0_OVF_vect) WinAVR avr/interrupt.h

TCCR0 Timer/Counter0 Control Register

FOC0 = 0 // bit

TCCR0

TCCR0

/0 (prescaler) TCCR0=0x05 //0000101 CLKtos/128 (from prescaler)

TCNT0 Timer/Counter Register

Count

TIMSK Timer/Counter Interrupt Mask Register

, TIMSK=0x01;

TCCR0 & TCNT0 & TIMSK

8 1 16

CODE

(1/2)

(2/2)

Search related