SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on the software and hardware for Atmel's STK standard.
By Athul
#201142
I learing AVR programming,

I have made a code to toggle AVR pin at an interval using interrupts

Here' the code
Code: Select all
#include <avr/io.h>
#include <avr/interrupt.h>

// initialize timer, interrupt and variable
void timer1_init()
{
    // set up timer with prescaler = 64 and CTC mode
    TCCR1B |= (1 << WGM12)|(1 << CS11)|(1 << CS10);

    TIMSK1 |= (1 << OCIE1B);        // Output Compare B Match Interrupt Enable
    // initialize counter
    TCNT1 = 0;

    // initialize compare value
    OCR1B = 7812;
    sei();
}


ISR(TIMER1_COMPB_vect) { 
    PORTC ^= (1 << 0);
}

int main(void)
{
    // connect led to pin PC0
    DDRC = 0XFF;

    // initialize timer
    timer1_init();

    // loop forever
    while(1)
    {

    }
}
But pin is not toggling? Why?
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]