2019-01-21 04:43 AM
I have a question out of curiously, how the values inside the huart1 initialized with some values without any function calling.. the breakpoints is at start of main()
2019-01-21 05:10 AM
huart1 is an uninitialized global variable, being in .bss section[1] (or equivalent) it shouldn't have any initialized values until the MX_USART1_UART_Init is called. C standard doesn't require uninitialized data to be zeros.
I guess when you are restarting your debugging session, the microcontroller's SRAM isn't being reset (no power off-on) so you are inheriting some "garbage" data from the previous session.
2019-01-21 05:46 AM
tried unplugging the power.. and it's the same. somehow it's initialized to 0 ..
2019-01-21 05:59 AM
Local/auto variables will contain random stack junk unless explicitly initialized.
2019-01-21 06:01 AM
To zero? That's OK, I thought by "initialized with some values" you meant something non-zero. I was wrong about the C standard:
If an object that has static storage duration is not initialized explicitly, it is initialized implicitly as if every member that has arithmetic type were assigned 0 and every member that has pointer type were assigned a null pointer constant.
So the startup code does initialize the bss section with zeros. The startup code is being called before main.