Program hangs after overflow interrupt of TCC4 atxmega32e5

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,

currently i'm experimenting with the xmega-e5 xplained board. Or should i say i want to start experimenting!? I develop on linux and at the moment i have no possibility to debug the device.

I started with a simple "Hello World"-LED-Blink program, that worked fine. Then i continued with a simple Interrupt test. For that i have chosen to test the overflow interrupt of TCC4.

The corresponding code is:

#include 
#include 

#define F_CPU 2000000

#include 

ISR (TCC4_OVF_vect)
{
    PORTA.OUTSET = PIN0_bm;
}

int
main (void)
{
    TCC4_CTRLA = TC45_CLKSEL_DIV256_gc;
    TCC4_INTCTRLA = TC45_OVFINTLVL_LO_gc;

    PMIC_CTRL = PMIC_LOLVLEN_bm;

    PORTA_DIR = PIN0_bm;
    PORTD_DIR = PIN4_bm;

    sei ();

    while (1) {
        PORTD.OUTSET = PIN4_bm;
        _delay_ms (1000);
        PORTD.OUTCLR = PIN4_bm;
        _delay_ms (1000);
    }

    return 0;
}

A LED is connected to both PIN4 of PORTD (LED0) and PIN0 of PORTA (LED1).

The timing is as follows:
LED0 blinks until LED1 went on. After that no blinking occurs anylonger. It just seems that the program hangs at this stage.

Maybe someone of you experts can give me a hint of what i did wrong!?

Thanks in advance and best regards...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

You need to clear the interrupt flag in the ISR, otherwise the interrupt will trigger over and over again. So your program doesn't really "hang", it's just very slow. ISR, one instruction in main, ISR, one instruction in main and so on.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks a lot for your help! Clearing the interrupt flag in the ISR resolved the alleged "hang". And of course it's in the manual :roll:

Nevertheless i'm pretty sure, that the corresponding interrupt flag on every member of the atxmegaXXXaX, atmega and attiny family I used in the past is cleared automatically when the interrupt vector is executed! The editor of the manual should have typeset the sentence that states the exception in bold letters.

Or better: In the future i must even be more concentrated while reading the register descriptions.

Best regards

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
You need to clear the interrupt flag in the ISR
WHAAATTT? Is this a specific issue to the overflow flag?

I use all 3 timers but in CTC mode so I don't use the OVF flag.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, it's only for the OVF-flag, and only for the E5 I think.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

snigelen wrote:
Yes, it's only for the OVF-flag, and only for the E5 I think.

Somebody can explain this?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can't explain the exception for the E5 not clearing the OVF flag within the interrupts, all other AVRs I have used all clear any flag which causes an interrupt as you enter the ISR automatically.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly