Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define F_CPU 8000000
- #include <avr/io.h>
- #include <avr/interrupt.h>
- void initClock()
- {
- // Setting CLKPSR does not affect the problem (It doesn't work regardless of what this is set to)
- // I have tried this before and after setting CLKMSR
- CCP = 0xD8;
- CLKPSR = 0;
- CCP = 0xD8;
- CLKMSR |= (1 << CLKMS1);
- }
- void initPorts()
- {
- DDRB |= (1 << PORTB0); // PB0 = OCR0A
- }
- void initTimer()
- {
- // I posted this code just in case, this works as expected (but only on the internal oscillator)
- // We want Compare Output Mode, Clear OC0A on Compare Match
- TCCR0A = (1 << COM0A0);
- // Overflow setting
- TIMSK0 |= (1 << OCIE0A);
- // We will not use a prescaler
- // This also starts the timer
- TCCR0B = (1 << CS00) | (1 << WGM02);
- // This is the value at which the timer will restart
- OCR0A = 8299;
- // Set external interrupts
- sei();
- }
- int main(void)
- {
- initClock();
- initPorts();
- initTimer();
- while(1)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement