I have been having a terrible time getting Serial communication working on the SAM R34 chip using ATMEL Studio 7.
Normally when asking I get the response "Check the example" (Spoiler alert, there is no example)
Anyhow, The code I have and I got from an example is:
#include <asf.h>
#include "sio2host.h"
#include "lorawan_app.h"
#include "pulse_counter.h"
#include "serial.h"
struct usart_module usart_instance;
int main(void)
{
system_init() ;
delay_init() ;
delay_ms(5) ;
Enable_global_interrupt() ;
sio2host_init() ;
pulse_counter_init() ;
lorawan_app_init() ;
lorawan_app_configuration(ISM_JPN923) ;
lorawan_app_join() ;
struct usart_config config_usart;
usart_get_config_defaults(&config_usart);
#if(SAMR30E)
{
config_usart.baudrate = 9600;
config_usart.mux_setting = CDC_SERCOM_MUX_SETTING;
config_usart.pinmux_pad0 = CDC_SERCOM_PINMUX_PAD0;
config_usart.pinmux_pad1 = CDC_SERCOM_PINMUX_PAD1;
config_usart.pinmux_pad2 = CDC_SERCOM_PINMUX_PAD2;
config_usart.pinmux_pad3 = CDC_SERCOM_PINMUX_PAD3;
while (usart_init(&usart_instance,
CDC_MODULE, &config_usart) != STATUS_OK) {
}
}
#else
{
config_usart.baudrate = 9600;
config_usart.mux_setting = EDBG_CDC_SERCOM_MUX_SETTING;
config_usart.pinmux_pad0 = EDBG_CDC_SERCOM_PINMUX_PAD0;
config_usart.pinmux_pad1 = EDBG_CDC_SERCOM_PINMUX_PAD1;
config_usart.pinmux_pad2 = EDBG_CDC_SERCOM_PINMUX_PAD2;
config_usart.pinmux_pad3 = EDBG_CDC_SERCOM_PINMUX_PAD3;
while (usart_init(&usart_instance,
EDBG_CDC_MODULE, &config_usart) != STATUS_OK) {
}
}
#endif
usart_enable(&usart_instance);
usart_serial_putchar(usart_inst_t, 'a');
while(1)
{
SYSTEM_RunTasks() ;
lorawan_app_sleep() ;
}
}
I am getting errors on the CDC_SERCOM_MUX_SETTING;
and each of the CDC_SERCOM_PINMUX_PAD0;
0-3 lines.
This code came directly from this guide: https://asf.microchip.com/docs/latest/sam0.drivers.tcc.unit_test.saml21_xplained_pro/html/asfdoc_sam0_sercom_usart_basic_use_case.html
however, it seems to not be valid.
any ideas at all on how to get this to work? It would be much appreciated!
Source: Windows Questions C++