Other Parts Discussed in Thread: C2000WARE
Tool/software:
Hi,
I have encountered a critical compiler (?) bug, where an attempt to call GPIO_writePin() from within CLA1 interrupt code causes the entire CPU to hang or otherwise execution seems to be lost in space.
Description
Trying set a GPIO pin, properly configured to be under CLA1 control, using the library GPIO_writePin() function called from within __interrupt void Cla1Task1 ( void ).
The CPU seems to stop running proper code altogether, interrupts no longer happening etc.
Investigating the crash, I have isolated the issue to the following line in GPIO_writePin():
pinMask = (uint32_t)1U << (pin % 32U);
Specifically, it is the "<<" operator on a variable that causes the crash. Changing to
pinMask = (uint32_t)1U << (9);
solves the issue.
Further Information
Using a cut&pasted my_GPIO_writePin() function in the .CLA file, I have changed the line to use a lookup table
static const uint32_t bitmap[32]={1<<0,
1<<1,
1<<2, ...
1U<<31};
:
:
pinMask = bitmap[pin%32];
And everything works as expected.
Calling GPIO_writePin() from the CPU (not CLA1) code always works as expected.
As I have found a workaround, I am submitting this issue as a bug report or otherwise for your analysis or to point me to where I have missed something.
Thank You,
-Alon