void Uart0_Init(uint32_t Baud)
{
/* Enable IP clock */
CLK_EnableModuleClock(UART0_MODULE);
/* Select IP clock source */
CLK_SetModuleClock(UART0_MODULE, CLK_CLKSEL1_UART_S_HXT, 0);
/*---------------------------------------------------------------------------------------------------------*/
/* Init I/O Multi-function */
/*---------------------------------------------------------------------------------------------------------*/
/* Set PB multi-function pins for UART0 RXD and TXD */
SYS->PB_L_MFP &= ~(SYS_PB_L_MFP_PB0_MFP_Msk | SYS_PB_L_MFP_PB1_MFP_Msk);
SYS->PB_L_MFP |= (SYS_PB_L_MFP_PB0_MFP_UART0_RX | SYS_PB_L_MFP_PB1_MFP_UART0_TX);
UART_Open(UART0, Baud);
/* Enable Interrupt and install the call back function */
UART_EnableInt(UART0, UART_IER_RDA_IE_Msk);
NVIC_EnableIRQ(UART0_IRQn);
}
void UART0_SendData(uint8_t *data, uint32_t len)
{
UART_Write(UART0, data, len);
}
/*---------------------------------------------------------------------------------------------------------*/
/* ISR to handle UART Channel 0 interrupt event */
/*---------------------------------------------------------------------------------------------------------*/
void UART0_IRQHandler(void)
{
UART0_TEST_HANDLE();
}
程序如上,初始化后,一直不进串口接收中断,不知道什么情况。后改用查询方式,发现当向单片机发送数据时,ISR的RDA_IS根本就不置位。官方的例程也试过了,同样的问题,发送正常,硬件没有问题。 |