Part Number: TM4C123GH6PM
Hi Team,
Good day. I am posting this inquiry on behalf of the customer.
"I am working with a program that attempts to access a GPIO port through the AHB. When compiled with -O0, everything works as expected and the disassembled pseudocode for this reads:
...STR instruction to enable the AHB for the GPIO portMOV instructions to prepare the GPIO port memory address needed nextLDR instruction to read the GPIO port through the AHB...
However, when compiled with -O1, a fault is thrown upon execution. I have narrowed down the cause of the fault to the above code section through debugging and found that the disassembled code this time is the same as above except that the MOV instructions are omitted (the memory address is instead prepared earlier in the code). So, it seems that enabling the AHB and then attempting to immediately access it in the very next instruction can cause issues.
My understanding is that this is due to one of two reasons:
1) there is an instruction synchronization issue occurring that requires an appropriate memory barrier to fix, or
2) there is a hardware latency issue occurring that requires an appropriate delay to transpire to fix.
If 1) is correct, then which barrier instruction should be inserted between the STR/LDR to resolve this? I wasn't able to identify an answer in the ARM Cortex-M Programming Guide to Memory Barrier Instructions Application Note. If 2) is correct, then what is the recommended way to ensure that the bus is ready to use upon enabling it? There is no associated ready-bit register to check for the buses like there is for the GPIO (PRGPIO), for example.
I believe it is 2) that is correct since the problem only occurs when executing the program at full speed and not when single-stepping over these instructions with a debugger (please correct me if this assessment is wrong). I also was unable to find any mention of such a sync/latency characteristic of the buses in the Tiva TM4C123GH6PM Microcontroller Data Sheet.
Any assistance is appreciated."
Please help to advise. Thank you for extending your support.
Kind regards,
Marvin