This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

msp430: crt0.S pokes at a wrong device address


Hi,

libgloss/msp430/crt0.S contains the following code:

    __start:
            ...
            ;; Disable watchdog timer.
            MOV     #0x5a80, &0x15C

This is not the correct address of the Watchdog Timer Control register
for all MSP430 MCUs.

The MSP430x1xx, MSP430x2xx, MSP430x4xx, and MSP430i2xx families have the
register at address 0x120.

The MSP430x5xx, MSP430x6xx, MSP430x09x, MSP430FRxx, and CC430 families
do use address 0x15c, except for the MSP430FR203x and MSP430FR413x,
where 0x15c is the System NMI Interrupt Vector Register, and the
watchdog is at 0x1cc.


I don't think it is possible to disable the watchdog from within
a portable assembler file like this, except by adding the WDTCTL address
to all the MCU-specific linker scripts.

It migher be a better idea to require that the watchdog is handled by
the program.  Other compilers have a weak function (_system_pre_init()
in CCS, __low_level_init() in IAR) that can be overridden to do this or
anything else that might be required before the data segment
initialization.  In gcc, I can get the same effect with a function like
this:

  #include <msp430.h>

  static void __attribute__((naked, section(".crt_0042"), used))
  disable_watchdog()
  {
      WDTCTL = WDTPW | WDTHOLD;
  }


Regards,
Clemens


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]