就是配置UART0是没有用UARTEnable函数,而在配置ADC、SPI等的时候有对应的这个ADCSequenceEnable、SSIEnable。额,这是为什么???
xyz549040622:
你加上这个,肯定是没错的。但为什么没加也可以用呢,有可能是你用的库中,比如初始化函数结束后,直接就在这个函数中使能了,但由于库是封装的,你看不到而已。
Maka Luo:
在调用这个函数中使能UART
voidUARTConfigSetExpClk(uint32_t ui32Base, uint32_t ui32UARTClk, uint32_t ui32Baud, uint32_t ui32Config){ uint32_t ui32Div;
// // Check the arguments. // ASSERT(_UARTBaseValid(ui32Base)); ASSERT(ui32Baud != 0); ASSERT(ui32UARTClk >= (ui32Baud * UART_CLK_DIVIDER));
// // Stop the UART. // UARTDisable(ui32Base);
// // Is the required baud rate greater than the maximum rate supported // without the use of high speed mode? // if((ui32Baud * 16) > ui32UARTClk) { // // Enable high speed mode. // HWREG(ui32Base + UART_O_CTL) |= UART_CTL_HSE;
// // Half the supplied baud rate to compensate for enabling high speed // mode. This allows the following code to be common to both cases. // ui32Baud /= 2; } else { // // Disable high speed mode. // HWREG(ui32Base + UART_O_CTL) &= ~(UART_CTL_HSE); }
// // Compute the fractional baud rate divider. // ui32Div = (((ui32UARTClk * 8) / ui32Baud) + 1) / 2;
// // Set the baud rate. // HWREG(ui32Base + UART_O_IBRD) = ui32Div / 64; HWREG(ui32Base + UART_O_FBRD) = ui32Div % 64;
// // Set parity, data length, and number of stop bits. // HWREG(ui32Base + UART_O_LCRH) = ui32Config;
// // Clear the flags register. // HWREG(ui32Base + UART_O_FR) = 0;
// // Start the UART. // UARTEnable(ui32Base);}