Content originally posted in LPCWare by marvic on Wed Aug 06 06:49:43 MST 2014
Hi,
I am using LPC mx-1114/301 board. Small piece of code written to send and receive the data to and from Hyper terminal.
Output, not showing typed data on terminal window. Any problem in source code? Can be appreciated to sort me out this. Here the code,
#include"lpc11xx_syscon.h"
#include"lpc11xx_gpio.h"
#include "lpc11xx_uart.h"
#include "LPC11xx.h"
#define SystemCoreClock 12000000UL
#define RDR 0x01
#define THRE 0x20
int main(void)
{
unsigned char data;
uint32_t baudrate = (uint32_t)115200 ;
uint32_t DL;
LPC_IOCON->PIO1_6 = 0x01;
LPC_IOCON->PIO1_7 = 0x01;
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<12);
LPC_SYSCON->UARTCLKDIV = 0x01; //UART clock
DL = (SystemCoreClock * LPC_SYSCON->SYSAHBCLKDIV) / (16 * baudrate * LPC_SYSCON->UARTCLKDIV);
LPC_UART->LCR = 0x83; //0x10000011;
LPC_UART->DLM = 0x01; //DL / 256;
LPC_UART->DLL = 0x86; // DL % 256;
LPC_UART->LCR = 0x03; //0x00000011;
LPC_UART->FCR = 0x07; //0x00000111;
while(1){
while (!(LPC_UART->LSR & RDR));
data = LPC_UART->RBR;
while (!(LPC_UART->LSR & THRE));
LPC_UART->THR = data;
}
}
Thanks,
Hi,
I am using LPC mx-1114/301 board. Small piece of code written to send and receive the data to and from Hyper terminal.
Output, not showing typed data on terminal window. Any problem in source code? Can be appreciated to sort me out this. Here the code,
#include"lpc11xx_syscon.h"
#include"lpc11xx_gpio.h"
#include "lpc11xx_uart.h"
#include "LPC11xx.h"
#define SystemCoreClock 12000000UL
#define RDR 0x01
#define THRE 0x20
int main(void)
{
unsigned char data;
uint32_t baudrate = (uint32_t)115200 ;
uint32_t DL;
LPC_IOCON->PIO1_6 = 0x01;
LPC_IOCON->PIO1_7 = 0x01;
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<12);
LPC_SYSCON->UARTCLKDIV = 0x01; //UART clock
DL = (SystemCoreClock * LPC_SYSCON->SYSAHBCLKDIV) / (16 * baudrate * LPC_SYSCON->UARTCLKDIV);
LPC_UART->LCR = 0x83; //0x10000011;
LPC_UART->DLM = 0x01; //DL / 256;
LPC_UART->DLL = 0x86; // DL % 256;
LPC_UART->LCR = 0x03; //0x00000011;
LPC_UART->FCR = 0x07; //0x00000111;
while(1){
while (!(LPC_UART->LSR & RDR));
data = LPC_UART->RBR;
while (!(LPC_UART->LSR & THRE));
LPC_UART->THR = data;
}
}
Thanks,
Hi,
Is there a specific reason for why you are writing your own code for UART? In case you did not know, we have a software platform called LPCOpen and there will be various drivers, including UART. You can download the platform here:
http://www.lpcware.com/content/nxpfile/lpcopen-software-development-platform-lpc11xx-packages-0
It does not seem like your board is supported, but the base UART initialization should be the same across all LPC11xx. As for debugging your current program, do you have access to an oscilloscope or logic analyzer? I would try to see if you initialized the UART correctly. Also make sure your initializing the same UART pins as the one that is connected to your computer!