Using print_dbg() function

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

Hi Freaks,

 

I am experimenting with AVR32UC3C and AVR ecosystem in general. Going step by step, I am facing something weird with a simple (I think it is) problem case. But I'm stuck. Here is my code :

 

#include <stdio.h>
#include <asf.h>
 
int main (void)
{
	/* Insert system clock initialization code here (sysclk_init()). */

	board_init();
	sysclk_init();
	init_dbg_rs232(sysclk_get_pba_hz());
	
	/* Insert application code here, after the board has been initialized. */

	char str[20];
	sprintf(str, "Hello World !\n");
	print_dbg(str);
	
	return 0;
}

 

I have added the "system clock controle" and "USART debug strings" services to the project with ASF Wizard.

 

When I debug it, when reaching the print_cbg(str) instruction, it feel like something is frozen. I have the Bray's terminal waiting anything but vain.

 

If someone has  any clue, I would appreciate.

 

Thank you in advance.

 

Gnull

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In embedded programming, main() should never return!  You need a forever loop! 

With most toolchains, when the main() exits, it turns off interrupts and goes into a forever loop of its own, if your usart needs interrupts to perform its output, you are out of luck.

 

Jim

 

Mission: Improving the readiness of hams world wide : flinthillsradioinc.com

Interests: Ham Radio, Solar power, futures & currency trading - whats yours?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gnull wrote:
I am experimenting with AVR32UC3C and AVR ecosystem in general.

 

https://www.avrfreaks.net/comment...

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello @ki0bk and @awneil !

 

First, thank you your answers. Second, sorry for my delayed response.

 

@ki0bk

You're right. I won't write this king of main anymore for embedded applications. ;)

 

@awneil

The reason why I tried UC3 was the 4+ USART channels in 5V... That allow me to restrict the number of parts on my board.

Last Edited: Mon. Mar 13, 2017 - 11:06 AM