SAME70 XPLAINED: CDC example program will not echo first character

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


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!

 

This topic has a solution.
Last Edited: Wed. Nov 13, 2019 - 08:17 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How about without the

		sleepmgr_enter_sleep();

?

/Lars

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Lars, and thank you for your response!

Commenting out the enter sleep statement didn't seem to make any difference. However, the Xplained was originally connected by USB through a docking station. I switched my mouse over to the docking station and plugged the Xplained directly into the computer, and that seems to have done the trick. Maybe a slow/bad connection, I don't know. Thank you either way!