Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

LPC1768 Uart Baud Rate Problema

Posted by Yuri Frehner on August 26, 2013
Hello, there is a question: I be using Free-RTos and have created a task to iniciate Uart on 115200 baud rate, but however all I do on configurations registers canĀ“t get right baud rate. For example, if I initiate Uart on 115200 I get 4800 on the terminal. I tried to implement the DLM and DLL starting a example code from hoan's blog, but nothing works on Free-Rtos, without Free-Rtos works normally. Can someone help me on this simple problem?

Using Keil, FreeRTOS V6.1.0 and NPX LPC1768 microcontroller

Uart Init Code:

void Uart0_Init(uint32_t baudrate)
{
uint32_t uClk;
uint32_t rate16 = 16 * baudrate;
uint32_t dval, mval;
uint32_t dl;
uint32_t rem;

uClk = CLKPWR_GetPCLK (CLKPWR_PCLKSEL_UART0);

rem = uClk % rate16;
dval = uClk % rate16;

if (dval > 0)
{
mval = rate16 / dval;
dval = 1;

// in case mval still bigger then 4 bits
// no adjustment require
if (mval > 12)
{
dval = 0;
}
}
dval &= 0xf;
mval &= 0xf;

dl = uClk / (rate16 + rate16 *dval / mval);

LPC_PINCON->PINSEL0 |= (1 << 4); /* Pin P0.2 used as TXD0 (Com0) */
LPC_PINCON->PINSEL0 |= (1 << 6); /* Pin P0.3 used as RXD0 (Com0) */

LPC_UART0->LCR = 0x83;
LPC_UART0->DLM = (((dl) >> 8) & 0xFF);
LPC_UART0->DLL = ((dl) & 0xFF);
/* Then reset DLAB bit */
LPC_UART0->LCR = 0x03; / */
LPC_UART0->FCR = 0x06;
}

RE: LPC1768 Uart Baud Rate Problema

Posted by Diptopal Basu on August 27, 2013
Your UART implementation generally falls outside of FreeRTOS. Probably where you might be getting stuck is initiating the UART in a task. Have you tried initialising UART in your 'main' before creating your tasks and then using the UART in your tasks? I have not tried out 115200 on my LPC1768 based board, I work on 38400. But ideally if your UART works , theres no reason it should not work on FreeRTOS. Have you tried using the CMSIS libraries, makes your life far easier?
Have you verified if your tasks are running properly on FreeRTOS? Are you on the Keil simulator or on a real hardware?

RE: LPC1768 Uart Baud Rate Problema

Posted by Yuri Frehner on August 27, 2013
Hello Diptopal, now I be testing your recommendations and soon as possible I will tell you the results. Thank you.

RE: LPC1768 Uart Baud Rate Problema

Posted by Yuri Frehner on August 29, 2013
Finally I get my project running. I followed your tips and had my LPC1768 running properly. All I done was starting of zero adding each kernel library from my working start project and then putting the UART_Init function before the tasks.
My Keil are simulating on a real hardware. Thank you very much.

RE: LPC1768 Uart Baud Rate Problema

Posted by Yuri Frehner on August 29, 2013
Finally I get my project running. I followed your tips and had my LPC1768 running properly. All I done was starting of zero adding each kernel library from my working start project and then putting the UART_Init function before the tasks.
My Keil are simulating on a real hardware. Thank you very much.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists