I have a school task but even the teacher don't know how to do it... We have to create a program that let the leds blink with a frequency of 1Hz. The chip we use is a ATmega32A at 3,6864 MHz. The program must contain interrupts so the main program can go to sleep.
now my question i have found SEI and the RETI functions but do i understand it correctly that i have to write 2 assembly programs?
1 with the main loop to control the leds.
1 that generates the 2Hz interrupt to toggle the leds?
tnx in advance
i have got the code working the following code is for a ATmega32A with a clock of 3686400Hz crystal
.org 0x000
rjmp reset
.org 0x00E
rjmp tc0_ocm_isr
.equ dirleds =DDRB
.equ leds =PORTB
.equ allout =0b1111_1111
.equ allin =0b0000_0000
.def temp = r16
.def allon = r17
.def ledtemp = r18
.def bitlow = r20
.def bithigh= r21
ldi ledtemp,0x00
ldi allon,0xff
reset:
ldi bithigh, 0x07
ldi bitlow, 0x07
out OCR1AH,bithigh
out OCR1AL,bitlow
ldi temp,0b00010000
out TIMSK,temp
ldi temp,0x0d
out TCCR1B,temp
sei
loop:
rjmp loop
tc0_ocm_isr:
eor ledtemp,allon
out DDRB,ledtemp
reti