I've been trying to set up a USART on an ATSAMD21E18A-MU
and have been running into issues.
Currently, I've narrowed the problem down to the fact that CTRLB.RXEN
and CTRLB.TXEN
never go high after enabling the USART.
My hardware has TX on PA04
and RX on PA06
. I'm trying to use OSC8M
as a source for Generator 3
, and Generator 3
for SERCOM0_CORE
. Trying to get everything relevant running at 8MHz.
I'm trying to set up 8n1, asynchronous mode, fractional baud rate, 16x oversampling, etc.
See this gist for the full example.
From the datasheet, info on CTRLB.RXEN
reads:
Writing '1' to CTRLB.RXEN when the USART is disabled will set CTRLB.RXEN immediately. When the USART is enabled, CTRLB.RXEN will be cleared, and SYNCBUSY.CTRLB will be set and remain set until the receiver is enabled. When the receiver is enabled, CTRLB.RXEN will read back as '1'.
(There is similar text for CTRLB.TXEN
.)
I spin check these flags after I enable the USART (line 115 and 116 in the gist) but they never go high.
Simple question: what am I missing?
I feel like I picked over the datasheet with a fine toothed comb...
Any and all help appreciated.
EDIT: discovered an issue with my use of PORT_WRCONFIG_PINMASK
in the example code (e.g. PORT_WRCONFIG_PINMASK(4)
vs. PORT_WRCONFIG_PINMASK(1<<4)
) but currently does not resolve the issue.