2024-02-04 07:07 AM - edited 2024-02-04 07:08 AM
Hi,
I am using random number generator of STM32F407VGT-DISC1, which generates values between 0 to 4294967295. In order to make sure if I get random value for debug purposes, I want to write this value to serial console via UART. When I write my code as attached, I cant see the value at the serial console as expected. The code calls the hard fault handler. Nothing written on the console.
Could anyone please help me with this ?
2024-02-04 07:51 AM
It's binary data, think Data Representation 101, if you need it in human-readable ASCII form you'll need to use sprintf() or itoa()
Hard Faulting as you're casting the value, not a pointer to the value.
HAL_UART_Transmit(&huart2, (uint8_t*)&random32bit, sizeof(random32bit),HAL_MAX_DELAY);
char string[16];
HAL_UART_Transmit(&huart2, (uint8_t *)string, sprintf(string,"%u\n", random32bit), HAL_MAX_DELAY);
2024-02-04 09:25 AM - edited 2024-02-04 09:26 AM
[deleted]