用STM32CubeMX生成代码。用串口USART1->RDR通过下面的代码获取字符。
char ReceiveAByteUART1 = '\0'; printf("\fHardware: STM32L4 Discovery kit IoT node (B-L475E-IOT01A)r\n>"); fflush(stdout); if(USART1->ISR & USART_ISR_RXNE) //Bit 5 RXNE: Read data register not empty { ReceiveAByteUART1 = getchar(); putchar(ReceiveAByteUART1); // Display a character. fflush(stdout); } 在STM32CubeIDE中运行,不能正确获取字符。 但是在Keil uVision5中能够正常。
|