[En-Nut-Discussion] Timer1, AT90CAN128 & NutOS
Jari Heikkilä
jaripetteri at gmail.com
Sat Jan 17 21:59:55 CET 2009
Thanks for you reply Harald.
>> http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=50106
>>
>
> This tutorial doesn't include interrupts, so it'd be interesting to see
> how you implemented them.
>
Either I have my terms mixed or you didn't read the part seven. Isn't
that overflow interrupt routine?
I have on main:
//enable interrupt
TCCR1A= 0x00; // Timer1 normal mode
TIMSK |= (1 << TOIE1); // Enable overflow interrupt
sei(); // Enable global interrupts
TCCR1B |= (1 << CS10); // Start timer at Fcpu/1
counter_500ms = 61;
pass_500ms = 0;
ISR Timer1 Overflow routine:
ISR(TIMER1_OVF_vect)
{
if(counter_500ms == 0)
{
pass_500ms = 1;
counter_500ms = 61;
}
counter_500ms--;
}
And I'll check 500ms pass flag on main loop with :
if(pass_500ms == 1)
> The AT90CAN128 is a bit different from the ATmega128, though.
>
> 1. Due to a bug on the chip, the stack needs to be in internal RAM.
> Nut/OS handles this automatically, when you selected the right MCU.
>
>
I use my own hw and there is no external RAM at all. This have already
been a problem and currently I have UART and CAN devices activated, only
main thread on use and currently 300 bytes RAM free. How much RAM that
timer1 overflow may use? any idea? And my CPU clock is 8Mhz since its
3.3V hardware.
> 2. The timer structure is different, actually similar to the ATmega256x.
> SO Nut/OS uses Timer2 for these chips, instead of Timer0 used for the
> m128. But Timer1 is OK.
>
>
Thats interesting. Basicly 90CAN128 should be Mega128 with CAN but after
all there are some annoying differences which I'll always learn the hard
way.
>> So is there sample anywhere how to use native Timer1 on NutOS? Or can anyone
>> give me some info how to go forward with this?
>>
>
> Yes, inside the OS: arch/avr/dev/ostimer.c.
> Because of the different options supported, it might be a bit difficult
> to read, though.
>
Thanks, I'll try to find the idea there.
Jari
More information about the En-Nut-Discussion
mailing list