When configuring TCA0 and enabling it's interrupt, it causes my ATmega4808 to reset. The reset actually occurs when I call sei()
But it will only reset once (after the initial reset), and then continue but the timer does not generate an overflow interrupt.
Another problem is when I enable the timer, all the interrupt flags are set.
The code is reduced to only the configuration of TCA0. Once TCA0 has been configured, I call the global interrupt enable with sei().
This is my current implementation:
// Stop timer TCA0.SINGLE.CTRLA &= ~(TCA_SINGLE_ENABLE_bm); // Force a hard reset TCA0.SINGLE.CTRLESET = TCA_SINGLE_CMD_RESET_gc; // Set the timer mode TCA0.SINGLE.CTRLB = TCA_SINGLE_WGMODE_NORMAL_gc; // Disable event counting TCA0.SINGLE.EVCTRL &= ~(TCA_SINGLE_CNTEI_bm); // Enable running in debug mode TCA0.SINGLE.DBGCTRL = TCA_SINGLE_DBGRUN_bm; // Set the period TCA0.SINGLE.PER = 63536; // Set the timer clock TCA0.SINGLE.CTRLA = TCA_SINGLE_CLKSEL_DIV1_gc; // Enable the timer TCA0.SINGLE.CTRLA |= TCA_SINGLE_ENABLE_bm; // Clear any pending interrupt flags TCA0.SINGLE.INTFLAGS = 0xFF; // Enable the interrupts TCA0.SINGLE.INTCTRL = TCA_SINGLE_OVF_bm;
Although I'm only interested in the overflow interrupt, I do have interrupt handlers for all the TCA interrupts.
1.) Why would I get a reset?
2.) Why are all the interrupt flags set?
3.) Why does the interrupt flags not clear when I try and clear them?
4.) Why will the timer not run?
Thanks in advance.