Poll
Question:
How can I use "printf" in STM32-H405.
Option 1: printf
votes: 0
Option 2: H405
votes: 0
Hi all.
I want to display with printf function from UART4 of H405 board.
I mate the following below.
*****************************************************************
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
PUTCHAR_PROTOTYPE
{
USART_SendData(UART_PORT[0], ch);
return ch;
}
void uart_debug()
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE);
UART_InitStructure.USART_BaudRate = 9600;
UART_InitStructure.USART_WordLength = USART_WordLength_8b;
UART_InitStructure.USART_StopBits = USART_StopBits_1;
UART_InitStructure.USART_Parity = USART_Parity_Odd;
UART_InitStructure.USART_Mode = USART_Mode_Rx|USART_Mode_Tx;
UART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_Init(UART_PORT[0], &UART_InitStructure);
printf("Debug Serial Test");
}
*****************************************************************
I wonder how the UART port is connected to the printf function.
If only PUTCHAR_PROTOTYPE is defined, can I use the "printf function" ?
Please let me know if you know anyone.
With so little info about tools etc it may be no-one can answer but instead of printf you could use sprintf then a loop to output each char to any uart.
John
Did you initialize the GPIO pins (GPIO_InitStructure) ?
Where is the USART enable USART_Cmd (COMxx, ENABLE) ?