ATmega16: TC0 kerdes
Daniel VASARHELYI
asd at mail.musichello.com
Sat Jan 3 10:37:23 CET 2004
Hali. Uj vagyok ATmega-ban, es lenne egy kerdesem.
1MHz-en jaratom belso RC oszcillatorral, a timer0 prescalerje 1024 es a
TCCR0 tulcsordulasakor meghivodik az OVF0 interrupt.
1 MHz/1024/256/2 = 1.9 hz. Megis inkabb 1Hz-nek tunik ez az ertek. Alant
mellekelem a sample programot, valaki megmondana, hogy min csusztam el?
asd
.include "m16def.inc"
.equ ProgStart =0x02a
.def blink_counter =r17
.def IRQ_SREG =r01
.def temp =r20
.def temp2 =r21
.org 0
rjmp RESET
.include "it-table.inc"
.org ProgStart
nullint:
reti
RESET:
ldi temp, low(RAMEND)
out SPL, temp
ldi temp, high(RAMEND)
out SPH, temp
ldi temp, 0b11111111 ; PORTB is output and switch it on
out DDRA, temp
out PORTA, temp
ldi temp, (1<<TOIE0) ; TC0 Overflow Interrupt Enable
out TIMSK, temp ; TC Interrupt Mask Register
ldi temp, 0b101 ; prescaler 1024
out TCCR0, temp ; TC Control Register
sei
forever:
nop
nop
nop
rjmp forever
OVF0_start:
in IRQ_SREG, SREG
inc blink_counter
out PORTA, blink_counter
out SREG, IRQ_SREG
reti
--
Daniel VASARHELYI
More information about the Elektro
mailing list