EmbDev.net

Forum: µC & Digital Electronics MSP430 WDT Application Problem?


Author: DeMiR X. (demir_x)
Posted on:

Rate this post
0 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

Author: TL431 (Guest)
Posted on:

Rate this post
0 useful
not useful
LED2 = !(IFG1 & WDTIFG);
This should do the same.

Author: DeMiR X. (demir_x)
Posted on:

Rate this post
0 useful
not useful
TL431 wrote:
>
> LED2 = !(IFG1 & WDTIFG);
> 
> This should do the same.

it decreases to errors to
"expression must be a modifiable value" in line 16 again

so what is wrong i can't find

Author: TL431 (Guest)
Posted on:

Rate this post
0 useful
not useful
>#define LED4 BIT1
How is LED4 defined?


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

if (IFG1 & WDTIFG) LED4_ON;
else               LED4_OFF;


Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.