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: Rune Christensen
Subject: RE: [avr-gcc-list] Timer Interrupt Problem on ATmega 103L
Date: Thu, 27 May 2004 01:46:33 +0200

Hello 

I will change 
        // Enable Interrupts (set TIMSK and then global interrupts)
        timer_enable_int(_BV(TOIE0));
to 
TIMSK |= _BV(TOIE0);

Give it a try, maybe it works ?!?!?

Cheers
Rune

-----Original Message-----
From: address@hidden
[mailto:address@hidden Behalf Of Andrew McNabb
Sent: Thursday, May 27, 2004 1:19 AM
To: address@hidden
Subject: [avr-gcc-list] Timer Interrupt Problem on ATmega 103L


I've been working with an ATmega 103L chip (on an STK300 board), and I'm
trying to use a timer overflow interrupt.  For some reason my interrupt
function never seems to get called, and I've spent hours trying to
figure out what I'm doing wrong.  I've even tried another 103L chip to
rule out this one being faulty.  I would greatly appreciate any help.

Well, my code's included a little ways down.  I tried to comment it
pretty well to show what I'm trying to do.

I noticed in one message in the archives that someone recommended
running avr-nm on the ELF file, so here's a part of the output:

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.

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;
        // 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;
}

_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.690 / Virus Database: 451 - Release Date: 22-05-2004

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.690 / Virus Database: 451 - Release Date: 22-05-2004



reply via email to

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