Problem with FreeRTOS+lwIP+USART on EVK1100

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

Hi,

I am working on my first Atmel UC3 application on EVK1100.

What I need to achieve is serial port (UART) functionality (receiving and sending data) together with TCP/IP socket server. I can get either serial port or socket server to work separately easily following the samples in Atmel Studio 7.

However, when I try to combine both functionalities, I run into the following issue.

The FreeRTOS+DHCP+lwIP example calls at the beginning sysclk_init() which calls:

case SYSCLK_SRC_PLL0: {
        pll_enable_config_defaults(0);
        // Set a flash wait state depending on the new cpu frequency.
        flash_set_bus_freq(sysclk_get_cpu_hz());
        sysclk_set_source(SYSCLK_SRC_PLL0);
        break;

 

this means the clock source is PLL here.

 

However, the serial port example sets the clock source to Oscillator in crystal mode:

pcl_switch_to_osc(PCL_OSC0, FOSC0, OSC0_STARTUP);

 

 

The problem is that when PLL is set as clock source in sysclk_init() my UART timing is not correct and I can only receive garbled data from it. When I remove the PLL setting in sysclk_init() or I remove sysclk_init() completely, serial port runs fine, however, now the TCP/IP server does not work.

Can you, please, explain to me what is wrong here and how can I configure UART so it will use the same PLL clock so both TCP server and UART work? Or should I completely reconfigure the UART?

 

Also, I have this note from Atmel:

http://www.atmel.com/Images/doc4...

 

which explains that there are special functions to use with UART under FreeRTOS. However, I am not able to find those functions anywhere in my Atmel Studio or ASF installation. Any idea if, how and when these should be used instead of standard UART functions from usart.c in ASF?

 

Thank you.

 

 

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

Solved.

Replace

#  define EXAMPLE_TARGET_PBACLK_FREQ_HZ FOSC0  // PBA clock target frequency, in Hz

with

#  define EXAMPLE_TARGET_PBACLK_FREQ_HZ 24000000  // PBA clock target frequency, in Hz

 

Not sure if this is the perfect solution and if there are any bad consequences, but for the moment it works.