On my SAMD21, I'm using the OSCULP32K as a real-time clock: I can put the processor into STANDBY mode and on a RTC count match, it wakes the processor up. Works fine.
Now I'd also like to wake the processor up when serial RX activity is detected. But I'm getting stuck in an apparent interrupt loop. Here's what I've done:
If I understand section 184.108.40.206 of the SAMD21 Family Datasheet correctly, I should:
- Reconfigured the clocks so the SERCOM3 Slow input is derived from the RTC (which is always running)
- Enabled Start Of Frame detection (CTRLB.SFDE) to detect onset of an incoming character
- Enabled Receive Start Interrupt Enable (INTENSET.RXS) to wake the processor at the onset of an incoming character
(Aside: I know that if my baud rate is high and my processor clock is slow to wake, then I ight ot eceive he irst haracter orrectly.)
Steps 1 and 2 I did via Atmel START (i.e. the Clocks screen and the SERCOM3 advanced settings, respectively). I didn't see any high-level functions for enabling INTENSET.RXS, so I just called:
in my startup code. Everything seems to work until I type a single character, at which point the code goes into a continual loop inside _sercom_usart_interrupt_handler().
My guess is that _sercom_usart_interrupt_handler() isn't set up to clear RXS interrupts, so the interrupt bit never gets cleared and it continually re-interrupts. (The good news: enabling RXS interrupts definitely wakes the processor.)
So my questions:
- Is my theory about RXS interrupts not getting cleared correct? If not, what should I look for?
- Is there a way to clear the RXS interrupt without modifying the ASF source code? (I didn't see one)