STM32F401RET6 LQFP64 (Nucleo-F401RE) uart 打印输出
1.STM32F401RET6 芯片情况
2.板子硬件
电源部分,开发板可利用JP5跳帽座子来选择使用USB供电或者使用管脚座子的外部Vin进行供电,无论是哪种供电,都需要经过U4的5V转成3.3V的LDO的再给STM32供电。
电路原理图,分为四部分:整体框架图、MCU的电路图、STLINK电路图、连接座管脚图。
2.1 连接座子 PIN含义
2.2 UART配置
*/
int main(void)
{
/* STM32F4xx HAL library initialization:
- Configure the Flash prefetch, instruction and Data caches
- Configure the Systick to generate an interrupt each 1 msec
- Set NVIC Group Priority to 4
- Global MSP (MCU Support Package) initialization
*/
HAL_Init();
/* Configure the system clock to 84 MHz */
SystemClock_Config();
/*##-1- Configure the UART peripheral ######################################*/
/* Put the USART peripheral in the Asynchronous mode (UART Mode) */
/* UART1 configured as follow:
- Word Length = 8 Bits
- Stop Bit = One Stop bit
- Parity = ODD parity
- BaudRate = 9600 baud
- Hardware flow control disabled (RTS and CTS signals) */
UartHandle.Instance = USARTx;
UartHandle.Init.BaudRate = 115200;//9600;
UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
UartHandle.Init.StopBits = UART_STOPBITS_1;
UartHandle.Init.Parity = UART_PARITY_NONE;//UART_PARITY_ODD;
UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
UartHandle.Init.Mode = UART_MODE_TX_RX;
UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;
if(HAL_UART_Init(&UartHandle) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/* Output a message on Hyperterminal using printf function */
printf("\n\r UART Printf Example: retarget the C library printf function to the UART\n\r");
//printf("ABCD\n\r");
/* Infinite loop */
while (1)
{
printf("ABCD\n\r");
//printf("\n\r UART Printf Example: retarget the C library printf function to the UART\n\r");
}
}
2.3 UART 2 默认连接到 ST LINK
2.3.1 ST LINK虚拟UART打印乱码
UartHandle.Init.Parity = UART_PARITY_NONE;//UART_PARITY_ODD;
UART打印终端与MCU UART配置不一致
改成无校验即可
2.4 MCU 自身的UART2 接口D1 D0无法 打印输出
短接SB63即可
3.参考
本地电脑工程路径:
D:\st mcu\STM32F401RE Nucleo-64开发板\stm32cube_fw_f4_v1260\STM32Cube_FW_F4_V1.26.0\Projects\STM32F401RE-Nucleo\Examples\UART\UART_Printf\MDK-ARM
32cube_fw_f4_v1260\STM32Cube_FW_F4_V1.26.0\Projects\STM32F401RE-Nucleo\Examples\UART\UART_Printf\MDK-ARM
超低功耗新标准——Nucleo-L073RZ评测 https://www.21ic.com/evm/evaluate/MCU/2016