2020-07-23 08:54 AM
Hello,
I'm working with the NUCLEO-F722ZE EVB on STM32CubeIDE.
I want to use the main USB connection to the PC as a UART.
The default CubeMX pin configuration already has PD8 and PD9 configured as a UART, so I proceeded with code generation (the auto generated main.c file is attached).
What's the recommended function I to print characters to the PC terminal over the UART ?
For example, if I want to send: "Hello World".
What would be the code for it ?
2020-07-24 11:13 PM
otherwise, try for run to get an HC-06 BT dongle (few bucks) and plug it on a free usart. It's 3.3 or 5V powered, 4 wires, then you can work wirelessly even when STlink is removed or your app is reloaded. The default speed is 9600bps and with the well documented AT+BAUD8 you can reprogram it to 115200bps which works reliably (don't try higher baud rate if sending continuously, BT packetize+timeout+buffer_when_out_of_range_momentaritly)
And you can even use it with remote display on open plateforms such as android (look at Bluetooth Electronics in Play Store)
2020-07-25 05:54 AM
I don't use hal, but I'm pretty sure it's not gonna work if you don't pass the address of the buffer to the hal transmit function. Clive's code passes the address of the buffer to his tansmit function, so there is (void *) cast in the hal function call to keep the compiler quiet. You need the & operator to dereference ( get the address of ) the buffer.
2020-07-25 11:43 AM
2020-07-25 01:30 PM
Forget all of that and use the register interface. A debugger, the reference manual and a decent knowledge of C is all you need. HAL is a perfect example of why you shouldn't use others code.