2018-11-22 08:10 AM
I am single stepping through simple code. I have two similar similar lines in a loop. Single stepping only goes to the last of those lines. This is STM32F746 Discovery and Keil IDE.
while(9)
{
if(HAL_UART_Transmit(&UartHandle, (uint8_t*)"\0", 1, 5000)!= HAL_OK)
{
Error_Handler();
}
HAL_Delay(100);
if(HAL_UART_Transmit(&UartHandle, (uint8_t*)'\n', 1, 5000)!= HAL_OK)
{
Error_Handler();
}
HAL_Delay(100);
}
2018-11-22 08:19 AM
I think this is the problem:
if(HAL_UART_Transmit(&UartHandle, (uint8_t*)'\n',
This seems to work:
if(HAL_UART_Transmit(&UartHandle, (uint8_t*)"\n",
2018-11-22 08:25 AM
You can't make a character into a pointer, that's not how this works. The function wants the address of a buffer, not the character you want to send..
We went over this in the previous thread.
2018-11-22 08:27 AM
The core functionality and compiler optimization work against you single stepping.
From the prior thread https://community.st.com/s/question/0D50X0000A1jvPMSQY/what-is-wrong-with-this-haluarttransmituarthandle-uint8t0
"The CM7 is a super-scaler pipelined architecture. Multiple non-conflicting instructions execute at once, and optimization can cause apparently non-sequential/out-of-order execution. Remember the C line may compile to multiple assembler instructions, and the granularity of the debugger's understanding of the code is one C line, which may be spread around. There might also be some core level errata related to revision/patch levels, because single stepping is an unnatural state for the core to be operating in.
I rarely use single stepping to understand what my code is doing, I can do static analysis to confirm the logic is correct, and if I want to know what the processor is doing, or likely to do, I read the assembler directly and follow that."
2018-11-22 09:07 AM
please check compiler option for optimizer level, i had similar problems which are gone mit
compiler option -O0 (Atollic) meaning: no optimization. In your toolchain the syntax may be different.
By the way: So far i know, CubeMX always will set a higher optimizer level by generating projects - so my first activity ist to switch off them again - afterwards no problems with stepping anymore.
2018-11-22 12:09 PM
I assumed that 'A' is a single byte but otherwise like "Ascii". This is what happens when I do this once or twice a year. I am really more a HW designer.
Yes, I suspected this had something to do with optimization. I have to check compiler settings, perhaps even study some C.
"so my first activity ist to switch off them again - afterwards no problems with stepping anymore." Good to know.