[Top][All Lists]

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

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

From: Andrew McNabb
Subject: [avr-gcc-list] Timer Interrupt Problem on ATmega 103L
Date: Wed, 26 May 2004 17:18:38 -0600
User-agent: Mutt/1.5.6i

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;

        // 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:
        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)

        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]