Quality RTOS & Embedded Software

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




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) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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

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

OpenRTOS and SafeRTOS