2021-01-13 01:03 AM
I could successfully build (with STM23CubeIDE) and run these projects:
STM32CubeF4\Projects\STM324xG_EVAL\Applications\mbedTLS\SSL_Client
STM32CubeF4\Projects\STM324xG_EVAL\Examples\UART\UART_Printf
As a next step I wanted to send out debug messages on the CN16 connector of the STM3240G-EVAL board while the SSL_Client example runs on it. Therefore I copied some function from the main.c of the UART_printf example to the main.c of the SSL_CLient example. However I could not send out any character because the program stopped if I uncommented the 125th row (which should send out the character 'A' on the RS232 port) in the attached main.c file. I this row was in comment the program could run just as the normal SSL_Client example. On the LCD the "HAL_UART_Init SUCCEED!" message always appears regardless if the program stops or not.
I guess some kind of vital configuration is missing but I have no useful idea (I had some ideas but they did not help...).
Does anybody have any idea how I could send out characters on the RS232 port?
Thanks in advance:
Simon
2021-01-13 01:22 AM
The document STM32 microcontroller debug toolbox - STMicroelectronics
describes, among others, how to printf debug.
hth
KnarfB
2021-01-13 01:50 AM
Thank you for your quick answer!
This document (Chapter 7.2 Printf via UART: page 61) refers exactly the same Uart_Printf example (STM32CubeF4\Projects\STM324xG_EVAL\Examples\UART\UART_Printf) which I used. Therefore this document does not contain any extra information for me.
I think that the method described in the Chapter 7.2 does not work in the SSL_Client example provided in the CubeF4 software package. Do you think that this method should work without other configurations? Because my experience is that other configurations are necessary which I could not find in the document which you have sent. At least not in the Chapter 7.2, but I doubt that there would be any information inconnection with this problem somewhere else in this document.
Regards,
Simon
2021-01-13 03:40 AM
The function name is crucial. It cannot be an arbitrary name as Uartprintf. The runtime has dummy "do nothing" implementations of IO base functions in which you override. Assuming gcc compiler (STM32CubeIDE) you may override __io_putchar or _write. Both are shown in that .pdf on page 60+61.
I.e. you put a user code block in main.c like
int _write(int file, char *ptr, int len)
{
HAL_UART_Transmit(&huart2, (uint8_t*)ptr, len, HAL_MAX_DELAY);
return len;
}
which overrides the weak _write in syscalls.c.
hth
KnarfB