Created
September 11, 2015 18:17
-
-
Save anonymous/96b75aba39286bc9a175 to your computer and use it in GitHub Desktop.
It works because the contents of wtf is now in a function...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* _8bitTimer.c | |
* | |
*/ | |
#include <avr/io.h> | |
#include <avr/interrupt.h> | |
// Port C LEDs | |
#define PC_LED1 0 | |
#define PC_LED2 1 | |
unsigned int extraTimer = 0; | |
unsigned int countLimit = 20; | |
unsigned int TcLedSignal = 1; | |
void wtf(); | |
int main(void) | |
{ | |
DDRC = (1 << PC_LED1) | (1 << PC_LED2); | |
PORTC &= ~3; | |
// Set Timer0 Prescaling | |
// 1024x prescale: | |
// 7.. 2 1 0 | |
// ... 1 0 1 | |
TCCR0 = 5; // 0b00000101. 1 its the number 1 in the 0th bit. | |
//set time to 0 for no reason, I'm pretty sure RESET defaults it to zero | |
//TCNT0 = 0; | |
// enable overflow interrupt | |
TIMSK = (1 << 0); // 0b00000001 | |
//global interrupt enable | |
sei(); | |
while(1) { | |
wtf(); | |
} | |
} | |
void wtf() | |
{ | |
if (TcLedSignal == 0){ | |
PORTC ^= ((1 << PC_LED1) | (1 << PC_LED2)); | |
TcLedSignal = 1; | |
} | |
} | |
ISR(TIMER0_OVF_vect) | |
{ | |
TCNT0 = 0; | |
extraTimer++; | |
if(extraTimer >= countLimit) | |
{ | |
//PORTC ^= ((1 << PC_LED1) | (1 << PC_LED2)); | |
TcLedSignal = 0; | |
extraTimer = 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment