I am trying to send the data to UART1 in LP2148. Given below is the code. But the data displayed is only some junk (mainly ???? is displayed). I am not able to makeout the problem. The terminal software is configured at 9600 baud. pclk is 15 MHz.
#include <lpc214x.h> //Includes LPC2148 register definitions
#define Fosc 12000000 #define Fcclk (Fosc * 5) #define Fcco (Fcclk * 4) #define Fpclk (Fcclk / 4) * 1
#define UART_BPS 9600 //Set Baud Rate here
const unsigned char SEND_STRING[] = "Nex Robotics PVT LTD\nARM7 LPC214x Development Board\nCommunication Test\nSend any character to continue\n"; const unsigned char SEND_STRING1[] = "Test Passed\n";
void Delay_Ticks(unsigned int Delay) //Function to generate finite delay { unsigned int i; for(; Delay>0; Delay--) for(i=0; i<50000; i++); }
void Init_UART1(void) //This function setups UART1 { unsigned int Baud16; U1LCR = 0x83; // DLAB = 1 Baud16 = (Fpclk / 16) / UART_BPS; U1DLM = Baud16 / 256; U1DLL = Baud16 % 256; U1LCR = 0x03; }
void UART1_SendByte(unsigned char data) //A function to send a byte on UART1 { U1THR = data; while( (U1LSR&0x40)==0 ); }
void UART1_SendStr(const unsigned char *str) //A function to send a string on UART1 { while(1) { if( *str == '\0' ) break; UART1_SendByte(*str++); } }
int main(void) { PINSEL0 = 0x00050000; // Enable UART1 Rx and Tx pins PINSEL1 = 0x00000000; PINSEL2 = 0x00000000;
Init_UART1(); UART1_SendStr(SEND_STRING); while((U1LSR&0x01)==0); UART1_SendStr(SEND_STRING1); while(1) {
} // return(0); }
If playing with boot loaders, then the PLL may not be configured in the way you thought in the processor - the USB interface has very specific requirements about clock speeds so an USB boot loader has to do much more work with the clocking than a serial-only boot loader.
Is your own code robust enough to be able to switch from PLL to RC clock, deactivate a running PLL, reconfigure the parameters of the PLL and spin it up again and after it has synchronized switch back to the PLL as clock source?