I have connected lpc 2368 to computer via uart-1 and using bioscom funtion in c++ i have made a programme to send and receive char through uart.my problem is that i can send char from lpc 2368 and able to receive it on pc but when i send it from pc i am unable to receive it on lpc 2368 board.
receiver code::
#include <LPC23xx.H> /* LPC23xx definitions */
#define UART1 /* Use UART 0 for printf */
/* If UART 0 is used for printf */ #ifdef UART0 #define UxFDR U0FDR #define UxLCR U0LCR #define UxDLL U0DLL #define UxDLM U0DLM #define UxLSR U0LSR #define UxTHR U0THR #define UxRBR U0RBR /* If UART 1 is used for printf */ #elif defined(UART1) #define UxFDR U1FDR #define UxLCR U1LCR #define UxDLL U1DLL #define UxDLM U1DLM #define UxLSR U1LSR #define UxTHR U1THR #define UxRBR U1RBR #endif
void init_serial (void) { /* Initialize Serial Interface */ #ifdef UART0 PINSEL0 |= 0x00000050; /* Enable TxD0 and RxD0 */ #elif defined (UART1) PINSEL0 |= 0x40000000; /* Enable TxD1 */ PINSEL1 |= 0x00000001; /* Enable RxD1 */ #endif UxFDR = 0; UxLCR = 0x83; UxDLL = 78; UxDLM = 0; UxLCR = 0x03; }
int getkey (void) { /* Read character from Serial Port */
while (!(UxLSR & 0x01));//it just wait hear for infinite time???
return (UxRBR); }
int main() {
char c; init_serial(); PINSEL10=0;
FIO2DIR0=0xff; FIO2CLR0=0xFF;
c=getkey();
FIO2SET0=0x01;//never reach to this point??? while(1);
}
plz help me....
Yes, the LPC23xx has power control bits for all devices. The user manual describes what these bits are, and their initial values.
UART0 and UART1 should be default on, while UART2 and UART3 is default off.
But haven't you looked at the Keil or the NXP example code for using the serial ports?
And how do you read a source code line like this:
Are you using a -1-relative indexing of the ports?
i have copied that def from serial.h file given in keil exampls. examples are there but i dont understand it...
and i have check the manual and defalt value is '1' means power is on.plz tell me what should i do?