同样的处理方法UART0、UART1正常,UART2、UART3死机,下面是那段程序: #include <LPC23xx.h> #define CR 0x0D void Delay(unsigned int cnt) { do { cnt--; } while(cnt!=0); } int sendchar0 (int ch) { if (ch == '\n') { while (!(U0LSR & 0x20)); U0THR = CR; /* output CR */ } while (!(U0LSR & 0x20)); return (U0THR = ch); } int sendchar1 (int ch) { if (ch == '\n') { while (!(U1LSR & 0x20)); U1THR = CR; /* output CR */ } while (!(U1LSR & 0x20)); return (U1THR = ch); } int sendchar2 (int ch) { if (ch == '\n') { while (!(U2LSR & 0x20)); U2THR = CR; /* output CR */ } while (!(U2LSR & 0x20)); return (U2THR = ch); }
int sendchar3 (int ch) { if (ch == '\n') { while (!(U3LSR & 0x20)); U3THR = CR; /* output CR */ } while (!(U3LSR & 0x20)); return (U3THR = ch); }main() { PINSEL0 |= 0x00000050; // Enable TxD0 and RxD0 PINSEL4 |= 0x0000000A; // Enable RxD1 and TXD0 PINSEL0 |= 0x00500000; // Enable TXD2 and RXD2 PINSEL9 |= 0x0F000000; // Enable TXD3 and RXD3 PINSEL10 = 0;
U0FDR = 0; U0LCR = 0x83; U0DLL = 16; U0DLM = 0; U0LCR = 0x03;
U1FDR = 0; U1LCR = 0x83; U1DLL = 16; U1DLM = 0; U1LCR = 0x03;
U2FDR = 0; U2LCR = 0x83; U2DLL = 16; U2DLM = 0; U2LCR = 0x03;
U3FDR = 0; U3LCR = 0x83; U3DLL = 16; U3DLM = 0; U3LCR = 0x03; while(1) { sendchar0(0x55); sendchar1(0x55); sendchar3(0x55); Delay(10000); } }
|