avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Timer Interrupt Problem on ATmega 103L


From: Petrik Gergely
Subject: Re: [avr-gcc-list] Timer Interrupt Problem on ATmega 103L
Date: Thu, 27 May 2004 08:22:17 +0200 (CEST)

Hello!

I'm a newbie on this list, and not veery well in English (but
I'm not the only one with that here :).

On Wed, 26 May 2004, Andrew McNabb wrote:

> 00000052 T __vector_16
>
> The datasheet says that OVERFLOW0 is vector 17, but I
assume that just
> has to do with starting from another base, and besides
that, if I set a
> handler for __vector_default, I still don't have any luck.
Yes, you are right. Somebody wrote exactly the same thing a few
days ago (ie gcc counts from 0, while the datasheet from 1).


> Thanks in advance for taking a look at this.
>
> -------------------------------------------------------
> #include <avr/io.h>
> #include <avr/interrupt.h>
> #include <avr/signal.h>
>
> long count = 0;
>
> SIGNAL (SIG_OVERFLOW0)
> {
>       // Flip the lights every time we get an overflow.
>       PORTB = ~PORTB;

try this instead, if you would like to see anything later:

        PORTB = ~PINB;

and use the plain method to activate the interrupt (by
... |= ... as Rune Christensen wrote). this may help, but I
don't know anyway, what does timer_enable_int() macro (?) do,
and how you should call it).

hope it helps.
--
G

>       // This doesn't happen.  The lights are constantly off.
>
>       /* I also tried this, which turns the lights on.  It didn't
>       do anything at all, so I feel safe assuming this function
>       is never entered even once. */
>       //PORTB = 0;
> }
>
> /* I tried this just in case, but it didn't help:
> INTERRUPT(__vector_default)
> {
>       PORTB = 0;
> }
> */
>
> int main()
> {
>       // Enable outputting to Port B;
>       DDRB = 0xff;
>
>       // Turn off all of the lights;
>       PORTB = 0xff;
>
>       // Set clock to Asynchronous Mode (use 32,768 Hz crystal)
>       ASSR = _BV(AS0);
>
>       // Scale to PCK0/128 (256 Hz)
>       TCCR0 = _BV(CS02) | _BV(CS00);
>
>       // Enable Interrupts (set TIMSK and then global interrupts)
>       timer_enable_int(_BV(TOIE0));
>       sei();
>
>       while (1) {
>               /* Uncommenting this produces the expected result:
>               the highest order bit flashes once a second, the
>               next twice a second, and so on (the lowest order
>               lights are a blur). */
>               //PORTB = ~TCNT0;
>       }
>
>       return 1;
> }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]