0
\$\begingroup\$

I am trying to learning about the Watch Dog Timer peripheral of MSP430FR6989 (link to MSP430).

It's Watch Dog Timer peripheral WDT_A have a 16 bit control register (WDTCTL), in order to perform a write operation, we need to load 0x5A in it's upper byte.

If we want to perform read operation we would read 0x69 to the upper byte.

(User Guide page 635)

write accesses must include the write password 05Ah in the upper byte. A write to WDTCTL with any value other than 05Ah in the upper byte is a password violation and causes a PUC system reset, regardless of timer mode. Any read of WDTCTL reads 069h in the upper byte.

This is my code:

#include <msp430.h> 

int main(void)
{
    WDTCTL = 0x5A80;
    PM5CTL0 = 0xFFFE;//Line A

    //rest of the code

    while(1);

    return 0;
}

When, I build it and debug it, and the debugger reaches line A, I expected WDTCTL = 0x5A80, not WDTCTL = 0x6980 (image below).

enter image description here

I understand, if I have a statement like if(WDTCTL == number), we would find WDTCTL = 0x69XX, but why do I see 0x6980 at the Register Watch Window, when I just assigned 0x5A80 to it.

\$\endgroup\$
  • \$\begingroup\$ I'm guessing WDTCTL is declared volatile. If so, what would you expect? \$\endgroup\$ – Brian Drummond Jul 20 '18 at 14:28
2
\$\begingroup\$

This is a special register. The upper byte is not like a regular register where setting it to 0x5Ann will read as 0x5Ann. The user guide explicitly tells you it will read as 0x69nn. Hardware wise in the block diagram for the watchdog, you see the upper byte is a password comparison EQU block. So you never actually write 0x5A to the upper byte, it goes to the comparison mechanism.

The 0x5A is a safety mechanism. The debugger is reading the actual register instead of following your code. The upper byte will always read 0x69 in the debugger.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.