I'm working on a K61 Cortex M4 controller and trying to access the watchdog timer output registers (0x40052000). I have several interrupt running, so reading the 16 bit register WDOG_TMROUTH and WDOGTMROUTL separately will sometimes cause a jump in value.
I want to know if it is possible to reading the WDOG_TMROUTH and WDOGTMROUTL register as a 32 bit access. I tried the following code
time = *((unsigned long*)(&WDOG->TMROUTH));
compiled to LDR in assembly. When the program reach the above code, it triggers a system hard fault.
When I modify the code to be a 16 bit access instead of 32 (compiled to LDRH in assembly), the assignment works fine.
I wonder if watchdog register specifically forbids 32 bit access (to the point where they flipped register's high and low order)?
Not just TMROUT, but also STCTRL, TOVAL and WIN.
Many thanks for the explanation!