so I work on a project, that needs to call a function on a regular 1ms basis. The simplest solution that I came up with is implement this via timer interrupt.
As you may guess, I failed.
The timer is running but the ISR is not fired. I'm checking this via breakpoints. (one in the main-while-loop, the other in the interrupt)
I had a look at the disassembly, there I saw, that enable global interrupts has been optimized away.
But thats not all. If I remove "Disable_global_interrupt();" then the Interrupt is instantly fired after the interrupt was set up and after the ISR was completed the MCU is going into an "Bus Error Instruction Fetch" - Exception.
I've searched the Internet and the Datasheet for two days now, without finding any clues.
Does someone have any ideas how this can happen? Or how I should proceed?
here is all of my code:
volatile uint32_t counterVar = 0;
volatile uint32_t maincounter = 0;
INTC_register_interrupt(&timerISR_forABCC, AVR32_TC0_IRQ0, AVR32_INTC_INT0);
AVR32_TC0.channel.IER.cpcs = 1;
AVR32_TC0.channel.CMR.waveform.wave = 1;
AVR32_TC0.channel.CMR.waveform.wavsel = 2;
AVR32_TC0.channel.CMR.waveform.tcclks = 2;
AVR32_TC0.channel.RC.rc = 32000;
AVR32_TC0.channel.CCR.clken = 1;
AVR32_TC0.channel.CCR.swtrg = 1;
/* Replace with your application code */
maincounter = AVR32_TC0.channel->CV.cv;