Commit ef0b307a authored by kaspems's avatar kaspems
Browse files

Update Session2-LF/Timer/Timer/TIMER-LF.c

parent eed87fa2
...@@ -12,8 +12,7 @@ ...@@ -12,8 +12,7 @@
#include <util/delay.h> #include <util/delay.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
#define LED1 4 // port D #define LED0 5 // port D
#define LED2 5 // port D
...@@ -23,8 +22,7 @@ int main(void) ...@@ -23,8 +22,7 @@ int main(void)
First set up the LEDs like in the previous exercise. You can either copy paste from the previous exercise or start fresh. First set up the LEDs like in the previous exercise. You can either copy paste from the previous exercise or start fresh.
*/ */
PORTD.DIR = (1 << LED1) | (1 << LED2); PORTF.DIR = (1 << LED0);
PORTD.OUTTGL = (1 << LED1); //Starting with only 1 LED on
/*We will be using timer A that will trigger an overflow interupt. /*We will be using timer A that will trigger an overflow interupt.
This is a 16 bit timer that can run in 2 modes This is a 16 bit timer that can run in 2 modes
...@@ -61,10 +59,10 @@ int main(void) ...@@ -61,10 +59,10 @@ int main(void)
ISR(TCA0_OVF_vect){ ISR(TCA0_OVF_vect){
//Do something with the led(s), like toggle. //Do something with the led(s), like toggle.
PORTD.OUTTGL = (1 << LED1) | (1 << LED2); PORTF.OUTTGL = (1 << LED0);
//Clear the interrupt flag. //Clear the interrupt flag.
//If we do not clear the flag, we will instantly jump back into the ISR again //If we do not clear the flag, we will instantly jump back into the ISR again
TCA0.SINGLE.INTFLAGS = ( TCA_SINGLE_OVF_bm); TCA0.SINGLE.INTFLAGS = ( TCA_SINGLE_OVF_bm);
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment