We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello folks. I am attempting to test serial comms on the MCB2140. While I have tested transmit with strings and single characters, I have yet to get coherent data from a device into the LPC2148.
Here is the current, simple program I am using, modified from examples found on Keil's website.
#define CR 0x0D #include <LPC21xx.H> void init_serial (void); int putchar (int ch); int getchar (void); unsigned char test; int main(void) { init_serial(); while(1) { putchar('?'); //checks for working output putchar(getchar()); //Echo terminal } } void init_serial (void) /* Initialize Serial Interface */ { PINSEL0 = 0x00000005; /* Enable RxD0 and TxD0 */ //PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */ U0LCR = 0x00000083; /* 8 bits, no Parity, 1 Stop bit */ U0DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */ U0LCR = 0x00000003; /* DLAB = 0 */ } int putchar (int ch) /* Write character to Serial Port */ { if (ch == '\n') { while (!(U0LSR & 0x20)); U1THR = CR; /* output CR */ } while (!(U0LSR & 0x20)); return (U0THR = ch); } int getchar (void) /* Read character from Serial Port */ { while (!(U0LSR & 0x01)); return (U0RBR); }
Upon running, I see a question mark, like I expect, but no further data. I have a straight cable plugged into UART0, and hyperterminal configured for 9600 8N1. I also tested this on some old black box serial device, but had no better results. I expect it to wait for input (it does) and echo back from the hardware whatever key I send. Anyone able to help offer insight into the situation as to why I cannot receive?