Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

MSP430 WDT Application Problem?

Status
Not open for further replies.

orhanli1

Junior Member level 1
Joined
Apr 18, 2011
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,531
Hello everybody.

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


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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 C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#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
 

t_maggot

Member level 3
Joined
Nov 9, 2006
Messages
57
Helped
4
Reputation
8
Reaction score
2
Trophy points
8
Activity points
0
BITx is a number, PxOUT_bit.PxOUT_x is a bitfield structure variable :shock:

But you can avoid bitfields using

PxOUT |= BITx; //1
PxOUT &= ~BITx; //0
 

orhanli1

Junior Member level 1
Joined
Apr 18, 2011
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,531
yeah i know this but i didn'T change LED4=~IFG1_bit.WDTIFG; for avoiding bitfield structure variable


what the exact line must be??

thanks
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top