I’ve narrowed it down a bit further. To me, it seems like one of the “dsb” calls clears the register. I’ve modified the code like this, disabling interrupt processing after sleeping:
vPortSuppressTicksAndSleep()
…
xModifiableIdleTime = xExpectedIdleTime;
configPRE_SLEEP_PROCESSING( xModifiableIdleTime );
__asm volatile("mov %0, r7" : "=r" (test5257));
if( xModifiableIdleTime > 0 )
{
__asm volatile ( "dsb" ::: "memory" );
__asm volatile ( "wfi" );
__asm volatile ( "isb" );
}
configPOST_SLEEP_PROCESSING( xExpectedIdleTime );
//don't enable interrupt processing here, just to be sure...
//__asm volatile ( "cpsie i" ::: "memory" ); <-----------------
__asm volatile ("nop" ::: "memory");
__asm volatile ( "dsb" );
__asm volatile ( "isb" ); // <---------------------------------
__asm volatile("mov %0, r7" : "=r" (test5258));
using this code, “test5258” contains the value “0” → cleared. When i patch the hex file and replace the last “isb” call with a 4 byte “nop”, the register contains the correct value.
At this point, I don’t think this is a FreeRTOS problem. I think I will post a question in the arm community forum…