سلام
من یک کد دارم که برای راه اندازی uart0 و uart2 از کد های زیر استفاده کرده. حالا دوستان کمک کنند فانکشن مربوط به uart3 را هم بنویسیم.
من یک کد دارم که برای راه اندازی uart0 و uart2 از کد های زیر استفاده کرده. حالا دوستان کمک کنند فانکشن مربوط به uart3 را هم بنویسیم.
کد:
void UART0_Init (void)
{
uint16_t usFdiv;
/* UART0 */
LPC_PINCON->PINSEL0 |= (1 << 4); /* Pin P0.2 used as TXD0 (Com0) */
LPC_PINCON->PINSEL0 |= (1 << 6); /* Pin P0.3 used as RXD0 (Com0) */
LPC_UART0->LCR = 0x83; /* Allows you to set the baud rate */
usFdiv = (FPCLK / 16) / UART0_BPS; /* Set baud rate */
LPC_UART0->DLM = usFdiv / 256;
LPC_UART0->DLL = usFdiv % 256;
LPC_UART0->LCR = 0x03; /* Locked baud rate */
LPC_UART0->IER = 0x01; // Enable TX/RX interrupts
LPC_UART0->FCR = 0x06;
NVIC_EnableIRQ(UART0_IRQn);
}
کد:
void UART2_Init (void)
{
uint16_t usFdiv;
/* UART2 */
LPC_PINCON->PINSEL0 |= (1 << 20); /* Pin P0.10 used as TXD2 (Com2) */
LPC_PINCON->PINSEL0 |= (1 << 22); /* Pin P0.11 used as RXD2 (Com2) */
LPC_SC->PCONP = LPC_SC->PCONP|(1<<24); /*Open UART2 power control bit */
LPC_UART2->LCR = 0x83; /* Allows you to set the baud rate */
usFdiv = (FPCLK / 16) / UART2_BPS; /* Set baud rate */
LPC_UART2->DLM = usFdiv / 256;
LPC_UART2->DLL = usFdiv % 256;
LPC_UART2->LCR = 0x03; /* Locked baud rate */
LPC_UART2->IER = 0x01; // Enable TX/RX interrupts
LPC_UART2->FCR = 0x06;
NVIC_EnableIRQ(UART2_IRQn);
}










دیدگاه