Other Parts Discussed in Thread: LAUNCHXL-F28379D
Over the past several weeks I have been corresponding with TI guru Ki re: an apparent problem correctly executing C/C++ if / else statements when a DSS script uses the asm("<label>:") construct to mark locations in code where the DSS script defines breakpoints. At first I thought the problem lay in faulty builds of TI demo boards. My most recent tests used 5 different TI demo boards, one controlCARD and 4 different LaunchXL-F28379D boards. All behaved the same way. Here is a description of my tests.
The test program reads from two GPIO pins (52 and 67). The test software succeeds if one input is high and the other low. VALID_CASE_0 occurs if GPIO67 is low and GPIO52 is high. VALID_CASE_1 occurs if GPIO67 is high and BPIO52 is low. INVALID_GPIO_INPUTS is returned If the two pins match, either both high or both low. This approach makes it easy to test different paths through the if / else logic with no changes to the firmware.
I have tested behavior with CCS version 10.4 using compiler version 20.5 and with CCS version 12 and compiler version 22.6. Results are the same. NOTE: Results DO change with project compiler optimization level. The results listed here are with optimization level 1: Local Optimizations.
Output from the 3 test cases were as shown below for all the demo boards:
GPIO52=1, GPIO67=0: Correct if execution, results are: VALID_CASE_0, TEST_IS_DONE
GPIO52=0, GPIO67=1 Faulty if execution, results are: VALID_CASE1, VALID_CASE_0, TEST_IS_DONE
GPIO52=1, GPIO67=1 Faulty if execution, results are: INVALID_GPIO_INPUTS, VALID_CASE_0, TEST_IS_DONE
In all 3 cases, the first if case reported IS the correct one, but when there is apparent faulty if execution, the breakpoint for a 2nd if /else case is also hit before the program exits the if / else cases entirely.
I tested a hypothesis that the if / else failure occurs under a DSS debug session when the asm("<label>:") statement is the last statement in an if / else case. In the test program, I moved the asm(*) statements above the last executable line in each if / else case. Now DSS executes the debug session correctly for all 3 test cases. So it does appear that a C2000 compiler bug may be placing the breakpoint label in the wrong location if the if / else logic if the label is the last statement in an if or else case. The work-around once the problem is understood is to move the breakpoint label so it is not the last statement in an if or else case.
Here is a ZIP file containing the CCS project. The DSS script is in folder JVScript.
