Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
avrkurs
avrkurs
Commits
ef0b307a
Commit
ef0b307a
authored
May 04, 2021
by
kaspems
Browse files
Update Session2-LF/Timer/Timer/TIMER-LF.c
parent
eed87fa2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Session2-LF/Timer/Timer/TIMER-LF.c
View file @
ef0b307a
...
...
@@ -12,8 +12,7 @@
#include <util/delay.h>
#include <avr/interrupt.h>
#define LED1 4 // port D
#define LED2 5 // port D
#define LED0 5 // port D
...
...
@@ -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.
*/
PORTD
.
DIR
=
(
1
<<
LED1
)
|
(
1
<<
LED2
);
PORTD
.
OUTTGL
=
(
1
<<
LED1
);
//Starting with only 1 LED on
PORTF
.
DIR
=
(
1
<<
LED0
);
/*We will be using timer A that will trigger an overflow interupt.
This is a 16 bit timer that can run in 2 modes
...
...
@@ -61,10 +59,10 @@ int main(void)
ISR
(
TCA0_OVF_vect
){
//Do something with the led(s), like toggle.
PORT
D
.
OUTTGL
=
(
1
<<
LED
1
)
|
(
1
<<
LED2
);
PORT
F
.
OUTTGL
=
(
1
<<
LED
0
);
//Clear the interrupt flag.
//If we do not clear the flag, we will instantly jump back into the ISR again
TCA0
.
SINGLE
.
INTFLAGS
=
(
TCA_SINGLE_OVF_bm
);
}
\ No newline at end of file
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment