Interrupt problem with AVR32 and C++ (µC hangs on interrupt)

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

Hello,
I have a AT32UC3B1256 on a self designed board. I tested UART Interrupt within a C-Projekt. Something like this: (works fine)

   INTC_init_interrupts();
   INTC_register_interrupt(&itfUSB_ISR, UART_USB_INT, AVR32_INTC_INT2);
   UART_USB->ier = AVR32_USART_IER_RXRDY_MASK;
   Enable_global_interrupt();
}

__attribute__((__interrupt__)) void itfUSB_ISR()
{

}

But the Project should be coded in C++, so I created a C++-Projekt in AVR32 Studio and moved my files, changed from .c to .cpp.
All includes to the Framwork-Driver where put in:

extern "C" {#include "foo.h"}

Runs fine so far, but when an interrupt occurs, the µC hangs.
I'm using the USB-Bootloader with the trampoline. Starting the application with

"batchisp.exe" -device AT32UC3B1256 -hardware USB -operation START reset
80002000"

Normally a hardware reset restarts the application, a power-down is necessary to bootload something.
But when the µC is killed with the interrupt, a reset starts the bootloader.

I already found the post from kokog9 https://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=56352 and tried all exceptions.s, .S and .x files I could find in all different naming possibilites. But every combination, that compiled fine, results in the same problem.

Hopefully someone can help me.
Greetings from Germany
Thomas

Student at the University of Applied Sciences Ulm, Germany

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

Hello again...
I tried to solve my problems the over the last days. In this morning the post brought me my new mkII clone.
Fine so far, first time debugging a µC with breakpoints - works all, as far I can see now.

But I can't solve my problem. Here is my INT-configuration and the ISR-routine:

Disable_global_interrupt();
INTC_init_interrupts();
INTC_register_interrupt( &itfUSB_ISR, UART_USB_INT, AVR32_INTC_INT3);
Enable_global_interrupt();

[...]

UART_USB->ier = AVR32_USART_IER_RXRDY_MASK;
__attribute__((__interrupt__)) static void itfUSB_ISR(void)
{
   usart_bw_write_char(UART_USB, '-');
}

Everything in my code works fine, except of the interrupts. So here is what the Debugger says:

After starting a debug, it waits here until i click resume:

Then next time at the beginnging of main()

So now when a UART-RX INT occurs while the code is running in the while(1)-loop:

But when I'm at a breakpoint, sending a char to the AVR and then after one or two steps it looks like this:

So please, is there anybody out there who can tell me whats wrong? Or how I have to do INT configuration and routines correctly with a C++ project.

Greetings from a snow-white Germany
Thomas

Student at the University of Applied Sciences Ulm, Germany

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

Finally I got it. While playing around with the INTC example and rebuilding it as a C++ project I discovered following:
Creating a new C++ project, in the Linker options there is no "-march=ucr1 -Wl,--gc-sections". But in the example there is. Without it, I had the above described problems.
Maybe it helps someone..

Student at the University of Applied Sciences Ulm, Germany