MSP430 WDT Application Problem?

OP #2245808
Rate this post
• ▲ useful
▼ not useful
Hello everybody.

I took this program from Davie's book for MSP430-1121STK as well

Code:
Listing 8.1:  Program wdtest1.c to demonstrate the watchdog timer.

//  wdtest1 .c   -  trival   program   to  demonstrate     watchdog 
timer
//  Olimex   1121 STK   board ,  32 KHz  ACLK
//  J  H  Davies ,  2007 -05 -10;   IAR  Kickstart    version   3.42 A
// 
----------------------------------------------------------------------
# include   < io430x11x1 .h>                         //  Specific 
device
// 
----------------------------------------------------------------------
//  Pins   for  LEDs   and  button
# define   LED1      P2OUT_bit . P2OUT_3
# define   LED2      P2OUT_bit . P2OUT_4
# define   B1        P2IN_bit . P2IN_1
//  Watchdog    config :   active ,  ACLK /32768   ->  1s  interval ; 
clear   counter
# define   WDTCONFIG      ( WDTCNTCL | WDTSSEL )
//  Include    settings    for  _RST / NMI pin   here  as  well
// 
----------------------------------------------------------------------
void   main  ( void )
{
     WDTCTL   =  WDTPW   |  WDTCONFIG ;              //  Configure 
and  clear   watchdog
      P2DIR  =  BIT3  |  BIT4 ;                      //  Set  pins  with 
LEDs   to  output
      P2OUT  =  BIT3  |  BIT4 ;                      //  LEDs  off  ( 
active   low )
      for  (;;)   {                                  //  Loop  forever
           LED2  =  ˜ IFG1_bit . WDTIFG ;            //  LED2  shows 
state   of  WDTIFG
           if  (B1  ==  1)  {                        //  Button   up
                LED1  =  1;                          //  LED1  off
           } else   {                                //  Button   down
                WDTCTL   =  WDTPW   |  WDTCONFIG ;   //  Feed / pet 
kick  clear  watchdog
                LED1  =  0;                          //  LED1  on
           }
      }
}

and i changed it for MSP430FG4618 board.It's pin descriptions are 
different than above.

it is
Code:
#include <msp430.h>

#define LED4 BIT1
#define LED1 BIT2
#define SW1 BIT0

#define WDTCONFIG (WDTCNTCL|WDTSSEL)

void main (void)
{
  WDTCTL=WDTPW|WDTCONFIG;
  P5DIR=BIT1;
  P2DIR=BIT2;
  for(;;)
  {
    LED4=~IFG1_bit.WDTIFG;
    if(SW1==1)
    {
      WDTCTL=WDTPW|WDTCONFIG;
      P2OUT=BIT2;
    }
    else
    {
      P2OUT=0x00;
    }
  }
}
But when i compile i take 3 errors

-expected a field name
-expression must be a modifiable value
-identified "IFG1_bit" is undefined (all of are in line 16 LED2 = ˜ 
IFG1_bit . WDTIFG ; )

i feel that i have to change LED2 = ˜ IFG1_bit . WDTIFG
but what i must write instead of it
Guest #2248021
Rate this post
• ▲ useful
▼ not useful
>#define LED4 BIT1
How is LED4 defined?


You can solve this by something like that:
1
#define LED4_ON  P2OUT &=~ BIT0 // LED @ P2.0
2
#define LED4_OFF P2OUT |=  BIT0 // LED @ P2.0
3

4
if (IFG1 & WDTIFG) LED4_ON;
5
else               LED4_OFF;

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.