Adding UART functionality to Touch GFX project; STM32F429I-Discovery; Keil;
Hello,
I would like to have printf functionality added to to Touch GFX generated project.
hardware: STM32F429I-Discovery
IDE: Keil 5.27
I have generated project using Touch GFX, then I can compile project using keil and run on my target board, work fine. Now I would like to add printf functionality to it.
enable HAL_UART_Driver in stm32f4xx_hal_conf.h
#define HAL_SPI_MODULE_ENABLED
#define HAL_TIM_MODULE_ENABLED
#define HAL_UART_MODULE_ENABLED //Uncomment this line
/* #define HAL_USART_MODULE_ENABLED */
/* #define HAL_IRDA_MODULE_ENABLED */ in main.cpp I added function:
void UartInit(void){
huart1.Instance = USART1;
huart1.Init.BaudRate = 115200;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
HAL_UART_Init(&huart1);
}added re-direction to printf
#ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int std::fputc(int ch, FILE *f)
#endif /* __GNUC__ */
PUTCHAR_PROTOTYPE{
HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);
return ch;
}in main function, after hw_init(), I am calling UartInit(..) function
code compiles and runs fine.
when I try to printf something it looks like code is crushing... I try to use Keil step debugger and it is not letting me step through the code...
Any suggestions , recommendations how to enable printf.
Please advise at your earliest convenience.
Regards,
IB