I'm using Version: 5.3.0.00090 to compile a small function to disable the watchdog. I needed to implement the same function in a JavaScript function. As a time saver I looked at the generated ASM file thinking I'll just copy the constants from the assmebly so I don't have to look up all the constants. But I found a puzzling discrepancy in one line of the code, highlighted below.
./**
* Disables the watchdog while still retaining the settings.
*
*/
void wdDisable(void)
{
//Set the Hold Bit - Retain Current Setting | Password | Turn Off
WDTCTL = (WDTCTL & 0x00FF) | (WDTPW | WDTHOLD);
}
The following are defined in "msp430f2618.h" and the load map
WDTCTL = 0x120 WDTPW = 0x5A00 WDTHOLD = 0x0080
Here is the assembly code generated:
wdDisable:
;* --------------------------------------------------------------------------*
.dwcfi cfa_offset, 4
.dwcfi save_reg_to_mem, 16, -4
;** 52 ----------------------- WDTCTL = WDTCTL&0x7fu|0x5a80u;
.dwpsn file "../DeviceDriverLayer/Watchdog/Watchdog.c",line 52,column 2,is_stmt
MOV.W #127,r15 ; [] |52|
AND.W &WDTCTL+0,r15 ; [] |52|
OR.W #23168,r15 ; [] |52|
MOV.W r15,&WDTCTL+0 ; [] |52|
;** ----------------------- return;
The #127 constant should be #255. And the 0x7fu in the constant above should be 0xFFu.. The #23168 constant is correct.
The wdDisable function works. And the code generated sets bit 8 properly due to WDTHOLD.
But what about the rest of our code, where we frequently use hex constants? Is there are compiler option?
thanks for your help,
Steven Kraus
QiG group
skraus@qig.com