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

 

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

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

 

http://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