Hello! I just got the SAME70 Xplained and have been trying to get the CDC example in the ASF to work for some time. The code is a slightly modified version of the "USB Device CDC Example - SAME70-XPLD". I am trying to get the board so receive and echo from the terminal, and it seems to work.. sometimes. This is the main function:
int main(void) { irq_initialize_vectors(); cpu_irq_enable(); sleepmgr_init(); #if !SAM0 sysclk_init(); board_init(); #else system_init(); #endif ui_init(); ui_powerdown(); // Start USB stack to authorize VBus monitoring udc_start(); // The main loop manages only the power mode // because the USB management is done by interrupt uint8_t input; while (true) { sleepmgr_enter_sleep(); while (udi_cdc_is_rx_ready()){ input = udi_cdc_getc(); udi_cdc_putc(input); } } }
Running at 9600 baud and less seems to cause the least amount of trouble. When I run this and enter a data string into the terminal, it will always echo back everything but the first character. This is what I get back when entering "123456789\n":
It ate my god damn 1!
And when turning up the baud, more and more of the data seems to get lost in translation. This is what I get back when entering the same string a bunch of times at 115200 baud:
I tried all of the standard bauds from 9600 and up, but the echo loses more and more information. Is this a timing thing with the USB vs. core clocks? Or is there something wrong with the way I try to send or receive data? I am using Atmel Studio 7, with the built in data visualizer. I would greatly appreciate some help. Have a great day!