再发上初始化的代码,都是例程里面的,就是改了口线定义,按照硬件改成了自己用的口线,第三功能的。。熟悉的朋友帮忙分析分析给个提示吧。。谢谢。
LPC_PINCON->PINSEL4 &= ~0x0000000F; //TXD1 in P0.0,P0.1设置成第三功能,首先清成0,每根线占2位,低4位
LPC_PINCON->PINSEL4 |= 0x0000000A; //TXD1 in P0.0,P0.1设置成第三功能,再改成1010,每根线占2位
/* By default, the PCLKSELx value is zero, thus, the PCLK for
all the peripherals is 1/4 of the SystemFrequency. */
/* Bit 8,9 are for UART1 */
pclkdiv = (LPC_SC->PCLKSEL0 >> 8) & 0x03;
switch ( pclkdiv )
{
case 0x00:
default:
pclk = SystemFrequency/4;
break;
case 0x01:
pclk = SystemFrequency;
break;
case 0x02:
pclk = SystemFrequency/2;
break;
case 0x03:
pclk = SystemFrequency/8;
break;
}
LPC_UART1->LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
Fdiv = ( pclk / 16 ) / baudrate ; /*baud rate */
LPC_UART1->DLM = Fdiv / 256;
LPC_UART1->DLL = Fdiv % 256;
LPC_UART1->LCR = 0x03; /* DLAB = 0 */
LPC_UART1->FCR = 0x07; /* Enable and reset TX and RX FIFO. */
NVIC_EnableIRQ(UART1_IRQn);
LPC_UART1->IER = IER_RBR | IER_THRE | IER_RLS; /* Enable UART1 interrupt */
|