I have a simple bit of test code that runs on the DSK5510 evaluation board. It simply transfers DIL switch settings to the LEDs:
#define GET_USER_REG (*(volatile unsigned int*)0x300000)
#define SET_USER_REG(DATA) ((*(volatile unsigned int*)0x300000)=DATA)
void main()
{
for(;;)
{
SET_USER_REG(GET_USER_REG>>4);
}
}
This compiles and runs fine in code composer ver 2 but when I move to version 3.1 the code no longer works.
Looking at the assembly generated by the two CCS versions shows that CCS2 uses a BFXTR instruction to do the shift whereas CCS3.1 uses a (more readable) move with shift.
Inserting an asm(" NOP"); in the loop makes it work again which makes me think that this is some kind of pipeline problem.
I would like to understand this problem (it has ramifications beyond the test code). Should I be writing my C code differently to use memory mapped registers or is this a bug in the compiler?