Hi everybody,
i have a multithreaded application on a TI DM6437. Timers 1+2 are configured as
64Bit timer. Each thread should be able to read the current timer value which
means to read TIM12 and TIM34 as described in spru989.pdf. What would be the
correct way to do this?
1. Using IRQ-Disable/Enable
#define TIM12 *(volatile Uint32*)(0x01C21410)
#define TIM34 *(volatile Uint32*)(0x01C21414)
Uint64 getTimerVal()
{
unsigned int ret[2];
IRQ_DISABLE();
ret[0] = TIM12;
ret[1] = TIM34;
IRQ_ENABLE();
return *(Uint64*)ret;
}
2. Without IRQ-Disable/Enabel
#define TIM1234 *(volatile Uint64*)(0x01C21410)
Uint64 getTimerVal()
{
return TIM1234;
}
The first possibility seems to be save but the 2nd one is shorter and would not
need IRQ-Disable/Enable.
As I've seen in the disassembly, for reading the 64-Bit Register the LDDW
instruction is used, which would be an atomic operation. Spru989 says, that when
reading TIM12, TIM34 is copied to a shadow register. When reading TIM34 (a few
ns after TIM12), it is read from shadow register and I get the correct value.
What will the LDDW instruction do? Does it read first TIM12 and then TIM34 or
may it be the wrong order.
Thanks for your help,
Tobias