Hello! I study LPC1766, having trouble initializing 2 and 3 UART, I initialize all for example, when adding a row UARTInit (2, 57600); UARTInit (3, 57600); in main.s does not work even 0 and 1 UART. Help!
else if ( PortNum == 2 ) { LPC_PINCON->PINSEL0 &= ~0x00F00000; LPC_PINCON->PINSEL0 |= 0x00500000; /* RxD2 is P0.11 and TxD2 is P0.10 */
/* By default, the PCLKSELx value is zero, thus, the PCLK for all the peripherals is 1/4 of the SystemFrequency. */ /* Bit 16,17 are for UART2 */ pclkdiv = (LPC_SC->PCLKSEL1 >> 16) & 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_UART2->LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */ Fdiv = ( pclk / 16 ) / baudrate ; /*baud rate */ LPC_UART2->DLM = Fdiv / 256; LPC_UART2->DLL = Fdiv % 256; LPC_UART2->LCR = 0x03; /* DLAB = 0 */ LPC_UART2->FCR = 0x07; /* Enable and reset TX and RX FIFO. */
NVIC_EnableIRQ(UART2_IRQn);
LPC_UART2->IER = IER_RBR | IER_THRE | IER_RLS; /* Enable UART1 interrupt */ return (TRUE); }
else if ( PortNum == 3 ) { LPC_PINCON->PINSEL9 &= ~0x0F000000; LPC_PINCON->PINSEL9 |= 0x0F000000; /* RxD3 is P4.29 and TxD3 is P4.28 */
/* By default, the PCLKSELx value is zero, thus, the PCLK for all the peripherals is 1/4 of the SystemFrequency. */ /* Bit 18,19 are for UART2 */ pclkdiv = (LPC_SC->PCLKSEL1 >> 18) & 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_UART3->LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */ Fdiv = ( pclk / 16 ) / baudrate ; /*baud rate */ LPC_UART3->DLM = Fdiv / 256; LPC_UART3->DLL = Fdiv % 256; LPC_UART3->LCR = 0x03; /* DLAB = 0 */ LPC_UART3->FCR = 0x07; /* Enable and reset TX and RX FIFO. */
NVIC_EnableIRQ(UART3_IRQn);
LPC_UART3->IER = IER_RBR | IER_THRE | IER_RLS; /* Enable UART1 interrupt */ return (TRUE); }