I'm trying to receive some data via USART on Atmel SAMD20. I use usart_read_wait()
and usart_read_buffer_wait()
but they return with error: the first with STATUS_BUSY
and the second with STATUS_ERR_TIMEOUT
. Sending works great, I get all the bytes in Putty or minicom. Here is my code:
#include <asf.h>
static struct usart_config usart_conf;
static struct usart_module usart_mod;
int
main (void)
{
system_init();
usart_get_config_defaults (&usart_conf);
usart_conf.pinmux_pad0 = PINMUX_UNUSED;
usart_conf.pinmux_pad1 = PINMUX_UNUSED;
usart_conf.pinmux_pad2 = PINMUX_PA20D_SERCOM3_PAD2;
usart_conf.pinmux_pad3 = PINMUX_PA21D_SERCOM3_PAD3;
usart_init (&usart_mod, SERCOM3, &usart_conf);
usart_enable (&usart_mod);
stdio_serial_init (&usart_mod, SERCOM3, &usart_conf);
uint8_t buf[8];
enum status_code st = usart_read_buffer_wait (&usart_mod, buf, sizeof (buf));
printf ("Code: %d\r\n", st);
}
The uC is connected to the PC via USB-to-TTL serial adapter. I suspect that I did the pinmux configuration the wrong way. I don't really understand what pinmuxes and pads are. So how could I send some data to the uC?