JMGross wrote:
swallen wrote:
WDT_A register is defined wrong per the datasheet ().

from the listing:
00000150 l *ABS* 00000000 WDTCTL

from datasheet (SLAS612–SEPTEMBER 2008):

REGISTER BASE OFFSET
WDTCTL 0150h 0Ch (=0x15C)

Yes, you are right. Wrong offset in wdt_a.h. Fixed in repository:
http://mspgcc.cvs.sourceforge.net/viewvc/mspgcc/msp430-libc/include/msp430/wdt_a.h?r1=1.3&r2=1.4

It's not the only bug in wdt_a.h:

#define WDTPW               (0xA5<<8)

should read

#define WDTPW               (0x5A<<8)
This was fixed even early:
http://mspgcc.cvs.sourceforge.net/viewvc/mspgcc/msp430-libc/include/msp430/wdt_a.h?r1=1.2&r2=1.3

Some thing I had to fix in the default startup code is the default disabling of 
the WDT.
It's very simle: just add function named __low_level_init() with __attribute__((naked, section ".init3")) into your project. It replaces default peripheral init function. Library function looks like:
__attribute__((naked, section(".init3"))) void __low_level_init()
{
    WDTCTL = WDTPW + WDTHOLD;
}
don't forget extern "C" if you add this function into C++ source file.

You can also replace data init routines by redefining __do_clear_bss() and/or __do_copy_data() in section .init4 Don't forget __attribute__((naked))!

Redefining function _reset_vector__() replaces whole startup code except C++ static objects constructors.
It took quite some time after starting with MSPs and mspgcc until I noticed that the WDT is silently disabled right after reset and all triggering of it was void.
It's not safe at all to believe in default value in any peripheral sfr. I strongly recommend to explicitly init all used sfrs even with default values.

A wrong password together with a wrong register address wouldn't have changed anything ;)
;)

--
Regards,
  Sergey A. Borshch            mailto: [email protected]
    SB ELDI ltd. Riga, Latvia


Reply via email to