EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Watchdog timer

Started by GM M November 15, 2002
Hello All,

Once again i m caught up with a problem. Can anyone tell me how following line
of code can stop the WatchDog timer??


  WDTCTL= WDTPW + WDTHOLD;             

plz reply as soon as possible as this is quite urgent,,,

thankyou very much



---------------------------------





Beginning Microcontrollers with the MSP430

Hi.

Do you have the "MSP430x1xx Family User's Guide"? You will find
it as SLAU049B.

The Watchdog Timer Control Register is explained on page 9-3. Bit 7 is called
"HOLD", and on the next page you will see that this bit stops the
operation of the watchdog counter.

You also need to write the correct password to the register.

Eivind

--- In msp430@y..., GM M <gmm2064@y...> wrote:
> 
> Hello All,
> 
> Once again i m caught up with a problem. Can anyone tell me how following
line of code can stop the WatchDog timer??
> 
> 
>   WDTCTL= WDTPW + WDTHOLD;             
> 
> plz reply as soon as possible as this is quite urgent,,,
> 
> thankyou very much
> 
> 
> 
> ---------------------------------
> 
> 
> 


thankyou very much for ur reply....yes i have that guide and i have studied
about 10 times......what i cannot understand is ... why are the two values
added??? and this line stops the watchdog timer.... i.e. sets the HOLD bit to
1... if i want to set the bit back to zeroo... how can i do it???
thankx once again
 vikebo <vikebo@vike...> wrote:Hi.

Do you have the "MSP430x1xx Family User's Guide"? You will find
it as SLAU049B.

The Watchdog Timer Control Register is explained on page 9-3. Bit 7 is called
"HOLD", and on the next page you will see that this bit stops the
operation of the watchdog counter.

You also need to write the correct password to the register.

Eivind

--- In msp430@y..., GM M <gmm2064@y...> wrote:
> 
> Hello All,
> 
> Once again i m caught up with a problem. Can anyone tell me how following
line of code can stop the WatchDog timer??
> 
> 
>   WDTCTL= WDTPW + WDTHOLD;             
> 
> plz reply as soon as possible as this is quite urgent,,,
> 
> thankyou very much
> 
> 
> 
> ---------------------------------
> 
> 
> 


.



 



---------------------------------





This is superbasic programming stuf so I recommend you to get a beginners
book on programming C.

In the example with the watchdogtimer we are setting bits so instead of
adding values, we could or then together:

WDTCTL= WDTPW | WDTHOLD;

If you dont want the WDTHOLD bit set just do:

WDTCTL= WDTPW;

In general if there is just a single bit that you want to change you can
do:

REG &= ~BITMASK;

Setting is done by:

REG |= BITMASK;

And once again it looks much more civilised if you try to write proper
english instead of ( ur, plz, thankx and just a lot of
..................,,,,,,,,,,). It realy look stupid. And as another guy
pointed out, read the manual.

Jardar

On Fri, 15 Nov 2002, GM M wrote:

>
> thankyou very much for ur reply....yes i have that guide and i have
> studied about 10 times......what i cannot understand is ... why are the
> two values added??? and this line stops the watchdog timer.... i.e. sets
> the HOLD bit to 1... if i want to set the bit back to zeroo... how can i
> do it??? thankx once again
>  vikebo <vikebo@vike...> wrote:Hi.
>
> Do you have the "MSP430x1xx Family User's Guide"? You will
find it as SLAU049B.
>
> The Watchdog Timer Control Register is explained on page 9-3. Bit 7 is
called "HOLD", and on the next page you will see that this bit stops
the operation of the watchdog counter.
>
> You also need to write the correct password to the register.
>
> Eivind
>
> --- In msp430@y..., GM M <gmm2064@y...> wrote:
> >
> > Hello All,
> >
> > Once again i m caught up with a problem. Can anyone tell me how
following line of code can stop the WatchDog timer??
> >
> >
> >   WDTCTL= WDTPW + WDTHOLD;
> >
> > plz reply as soon as possible as this is quite urgent,,,
> >
> > thankyou very much
> >
> >
> >
> > ---------------------------------
> > 
>
>


Dear Jardar,
Thankyou very much for your reply. I am sorry if my typing style bothered you.
You will never see it again.
Coming back to the topic again. Thanks for this additional information which you
have given in your reply. Can you specifically tell me why we are adding the
password and hold bit
thankyou Very much
Waiting for your reply
 Jardar Johannes Maatje <maatje@maat...> wrote:This is superbasic
programming stuf so I recommend you to get a beginners
book on programming C.

In the example with the watchdogtimer we are setting bits so instead of
adding values, we could or then together:

WDTCTL= WDTPW | WDTHOLD;

If you dont want the WDTHOLD bit set just do:

WDTCTL= WDTPW;

In general if there is just a single bit that you want to change you can
do:

REG &= ~BITMASK;

Setting is done by:

REG |= BITMASK;

And once again it looks much more civilised if you try to write proper
english instead of ( ur, plz, thankx and just a lot of
..................,,,,,,,,,,). It realy look stupid. And as another guy
pointed out, read the manual.

Jardar

On Fri, 15 Nov 2002, GM M wrote:

>
> thankyou very much for ur reply....yes i have that guide and i have
> studied about 10 times......what i cannot understand is ... why are the
> two values added??? and this line stops the watchdog timer.... i.e. sets
> the HOLD bit to 1... if i want to set the bit back to zeroo... how can i
> do it??? thankx once again
>  vikebo <vikebo@vike...> wrote:Hi.
>
> Do you have the "MSP430x1xx Family User's Guide"? You will
find it as SLAU049B.
>
> The Watchdog Timer Control Register is explained on page 9-3. Bit 7 is
called "HOLD", and on the next page you will see that this bit stops
the operation of the watchdog counter.
>
> You also need to write the correct password to the register.
>
> Eivind
>
> --- In msp430@y..., GM M <gmm2064@y...> wrote:
> >
> > Hello All,
> >
> > Once again i m caught up with a problem. Can anyone tell me how
following line of code can stop the WatchDog timer??
> >
> >
> >   WDTCTL= WDTPW + WDTHOLD;
> >
> > plz reply as soon as possible as this is quite urgent,,,
> >
> > thankyou very much
> >
> >
> >
> > ---------------------------------
> > 
>
>


.



 



---------------------------------





At 08:56 PM 11/15/2002 -0800, GM M wrote:

>Dear Jardar,
>Thankyou very much for your reply. I am sorry if my typing style bothered 
>you. You will never see it again.
>Coming back to the topic again. Thanks for this additional information 
>which you have given in your reply. Can you specifically tell me why we 
>are adding the password and hold bit

The reason the add operator is used is that if the operands are bits, then 
adding them is the same as OR'ing them, e.g.
         WDTCTL= WDTPW | WDTHOLD;
is the same as
         WDTCTL= WDTPW + WDTHOLD;

>thankyou Very much
>Waiting for your reply
>  Jardar Johannes Maatje <maatje@maat...> wrote:This is superbasic 
> programming stuf so I recommend you to get a beginners
>book on programming C.
>
>In the example with the watchdogtimer we are setting bits so instead of
>adding values, we could or then together:
>
>WDTCTL= WDTPW | WDTHOLD;
>
>If you dont want the WDTHOLD bit set just do:
>
>WDTCTL= WDTPW;
>
>In general if there is just a single bit that you want to change you can
>do:
>
>REG &= ~BITMASK;
>
>Setting is done by:
>
>REG |= BITMASK;
>
>And once again it looks much more civilised if you try to write proper
>english instead of ( ur, plz, thankx and just a lot of
>..................,,,,,,,,,,). It realy look stupid. And as another guy
>pointed out, read the manual.
>
>Jardar
>
>On Fri, 15 Nov 2002, GM M wrote:
>
> >
> > thankyou very much for ur reply....yes i have that guide and i have
> > studied about 10 times......what i cannot understand is ... why are
the
> > two values added??? and this line stops the watchdog timer.... i.e.
sets
> > the HOLD bit to 1... if i want to set the bit back to zeroo... how can
i
> > do it??? thankx once again
> >  vikebo <vikebo@vike...> wrote:Hi.
> >
> > Do you have the "MSP430x1xx Family User's Guide"? You
will find it as 
> SLAU049B.
> >
> > The Watchdog Timer Control Register is explained on page 9-3. Bit 7 is

> called "HOLD", and on the next page you will see that this bit
stops the 
> operation of the watchdog counter.
> >
> > You also need to write the correct password to the register.
> >
> > Eivind
> >
> > --- In msp430@y..., GM M <gmm2064@y...> wrote:
> > >
> > > Hello All,
> > >
> > > Once again i m caught up with a problem. Can anyone tell me how 
> following line of code can stop the WatchDog timer??
> > >
> > >
> > >   WDTCTL= WDTPW + WDTHOLD;
> > >
> > > plz reply as soon as possible as this is quite urgent,,,
> > >
> > > thankyou very much
> > >
> > >
> > >
> > > ---------------------------------
> > > 
> >
> >
>
>
>.
>
>
>
>
>
>
>
>---------------------------------
>

// richard <http://www.imagecraft.com> 
<http://www.dragonsgate.net/mailman/listinfo>
On-line orders, support, and listservers available on web site.
[ For technical support on ImageCraft products, please include all previous 
replies in your msgs. ] 


Dear Richard,
Thankyou very much for your reply. I am grateful for your reply. But I am a
beginner and cannot understand why we are adding or applying OR here? Can you
just explain this to me in detail??
Thankyou Very much
 "Richard F. Man" <richard@rich...> wrote:At 08:56 PM 11/15/2002
-0800, GM M wrote:

>Dear Jardar,
>Thankyou very much for your reply. I am sorry if my typing style bothered 
>you. You will never see it again.
>Coming back to the topic again. Thanks for this additional information 
>which you have given in your reply. Can you specifically tell me why we 
>are adding the password and hold bit

The reason the add operator is used is that if the operands are bits, then 
adding them is the same as OR'ing them, e.g.
         WDTCTL= WDTPW | WDTHOLD;
is the same as
         WDTCTL= WDTPW + WDTHOLD;

>thankyou Very much
>Waiting for your reply
>  Jardar Johannes Maatje <maatje@maat...> wrote:This is superbasic 
> programming stuf so I recommend you to get a beginners
>book on programming C.
>
>In the example with the watchdogtimer we are setting bits so instead of
>adding values, we could or then together:
>
>WDTCTL= WDTPW | WDTHOLD;
>
>If you dont want the WDTHOLD bit set just do:
>
>WDTCTL= WDTPW;
>
>In general if there is just a single bit that you want to change you can
>do:
>
>REG &= ~BITMASK;
>
>Setting is done by:
>
>REG |= BITMASK;
>
>And once again it looks much more civilised if you try to write proper
>english instead of ( ur, plz, thankx and just a lot of
>..................,,,,,,,,,,). It realy look stupid. And as another guy
>pointed out, read the manual.
>
>Jardar
>
>On Fri, 15 Nov 2002, GM M wrote:
>
> >
> > thankyou very much for ur reply....yes i have that guide and i have
> > studied about 10 times......what i cannot understand is ... why are
the
> > two values added??? and this line stops the watchdog timer.... i.e.
sets
> > the HOLD bit to 1... if i want to set the bit back to zeroo... how can
i
> > do it??? thankx once again
> >  vikebo <vikebo@vike...> wrote:Hi.
> >
> > Do you have the "MSP430x1xx Family User's Guide"? You
will find it as 
> SLAU049B.
> >
> > The Watchdog Timer Control Register is explained on page 9-3. Bit 7 is

> called "HOLD", and on the next page you will see that this bit
stops the 
> operation of the watchdog counter.
> >
> > You also need to write the correct password to the register.
> >
> > Eivind
> >
> > --- In msp430@y..., GM M <gmm2064@y...> wrote:
> > >
> > > Hello All,
> > >
> > > Once again i m caught up with a problem. Can anyone tell me how 
> following line of code can stop the WatchDog timer??
> > >
> > >
> > >   WDTCTL= WDTPW + WDTHOLD;
> > >
> > > plz reply as soon as possible as this is quite urgent,,,
> > >
> > > thankyou very much
> > >
> > >
> > >
> > > ---------------------------------
> > > 
> >
> >
>
>
>.
>
>
>
>
>
>
>
>---------------------------------
>

// richard <http://www.imagecraft.com> 
<http://www.dragonsgate.net/mailman/listinfo>
On-line orders, support, and listservers available on web site.
[ For technical support on ImageCraft products, please include all previous 
replies in your msgs. ] 


.



 



---------------------------------





> Dear Richard,
> Thankyou very much for your reply. I am grateful
for your reply. But I am a beginner and cannot 
> understand why we are adding or applying OR here? Can you just explain this
to me in detail??
> Thankyou Very much

Hi man,

I'll quickly throw in 2 c worth too, but before doing so - 
I think you will find that very basic questions like you are asking will not get
much reply here,
this is a forum where people share findings, toolset issues, and general
"I'm stumped" stuff specific to MSP430.
But you've made a good choice ! You're starting to use MSP430, and
"C" will do a lot of the weird stuff for you,
but it's not a magic wand !!!
Also, this is not a class room forum for binary arithmetic.

Having said that, we all have been new to this - and "newbies" are
always welcome, as long as you don't
constantly "hog" the forum with things you should really learn
off-line.
We all still learn all the time, that's why we're all here.... and
otherwise it'd be boring anyway........

Very briefly :
-------------
The registers you are operating on are typically 8 bits (1 byte)  wide, some 16
bits (1 word).
As you found, at times you want to SET or CLEAR these bits, when they control
something.
The most common way to do so is to use binary operations, such as OR and AND.
(I assume you know that bitwise OR is :
0 OR 0 = 0
0 OR 1 = 1
1 OR 0 = 1
1 OR 1 = 1

and that bitwise AND is :
0 AND 0 = 0
0 AND 1 = 0
1 AND 0 = 0
1 AND 1 = 1
)

Consider this OR :
--------------------
1001 = 9 ( 1 * 2^3   + 1 * 2^0 )
Say you want to set bit # 2 in this number made of 4 bits ie. you want to make
1001 ---> into 1101    (bit 3 would be the most significant ie. 2 power 3 or
2^3, bit 0 the least significant ie. 2 power 0 = 2^0 = 1)

The easiest way to do this is to use the number :
0100 (which is 4) - as it has ONLY BIT 2 set to "1".

and OR it to set BIT 2 ->
1001     OR'd with
0100 -----
1101 (see modulo-2 add below)

An AND is typically used to CLEAR (set to 0) a bit :
---------------------
Again, take the number 1001 (9 decimal).
Say you want to clear BIT 3 now :
You work out now where to go from here :
(ie. how to use a "mask" by using the one's complement)

1001   AND
0111    -----
0001    -> bit 3 is now "0".

Maybe one word of caution that we all occasionally can overlook :
--
It is general practice (qwell I do too) to "add" the bits in that you
want set to "1", rather than ORing.
As above :
1001 +
0100 ------
1101 -> 13 decimal - or (9 + 4) which is the same as 

It is important that you understand that you can only use "add" if the
symbols that represent the bits, are made up of
only 1 bit set to "1", and also that the same bit position can only be
used ONCE

Eg :

1001 OR
0001 -----
1001

BUT :
==
1001 +
0001 -----
1010    (10 decimal , 9 + 1)
If the intention was here to set BIT 0 to "1", the add actually caused
it to clear to "0" !!!!!!!!
Keep this in MIND !!...........


In your example before :
WDTCTL= WDTPW + WDTHOLD;

WDTCTL is a register, and WDPTW / WDTHOLD are "symbols" representing
certain bit positions.
If both these bits need to be set, then the statement as above will ONLY set the
WDTPW (Watchdog password) and WDTHOLD (Hold) bits to "1", the others
will be "0".

If you go :
WDTCTL= WDTPW;
after having done the statement above, then you are re-writing to that WDTCTL
register -
this time with only the WDTPW bit set - in effect the WDTHOLD bit has been set
to "0" now.........


Maybe this will give you a "kickstart", but you REALLY will need to
get a good book on C, and preferably
one that starts from the start - ie. the Binary number system, and how to handle
Boolean stuff.

I personally liked Herbert Schildt's "C, the complete reference"
a lot to get a good grasp on the basics
of "C" - but everyone to their own.....
Try and learn these things as you go along, and post questions on things
specific to MSP430 here that
you are stuck with.
Newcomers one day become a source of knowledge too - so have fun / good luck !!!


Kris






At 08:04 PM 11/16/2002 +1100, Kris wrote:
>...
>Very briefly :
>-------------
>...

Kris, that's brief? I hate to see your verbose reply :-)

Nice explanation. May be I can hire you to write help files :-)


// richard <http://www.imagecraft.com> 
<http://www.dragonsgate.net/mailman/listinfo>
On-line orders, support, and listservers available on web site.
[ For technical support on ImageCraft products, please include all previous 
replies in your msgs. ] 


Dear Kris,
What can i say????? you have really helped me alot. All i can say is THANKYOU
VERY MUCH
take care
 Kris De Vos <microbit@micr...> wrote:> Dear Richard,
> Thankyou very much for your reply. I am grateful
for your reply. But I am a beginner and cannot 
> understand why we are adding or applying OR here? Can you just explain this
to me in detail??
> Thankyou Very much

Hi man,

I'll quickly throw in 2 c worth too, but before doing so - 
I think you will find that very basic questions like you are asking will not get
much reply here,
this is a forum where people share findings, toolset issues, and general
"I'm stumped" stuff specific to MSP430.
But you've made a good choice ! You're starting to use MSP430, and
"C" will do a lot of the weird stuff for you,
but it's not a magic wand !!!
Also, this is not a class room forum for binary arithmetic.

Having said that, we all have been new to this - and "newbies" are
always welcome, as long as you don't
constantly "hog" the forum with things you should really learn
off-line.
We all still learn all the time, that's why we're all here.... and
otherwise it'd be boring anyway........

Very briefly :
-------------
The registers you are operating on are typically 8 bits (1 byte)  wide, some 16
bits (1 word).
As you found, at times you want to SET or CLEAR these bits, when they control
something.
The most common way to do so is to use binary operations, such as OR and AND.
(I assume you know that bitwise OR is :
0 OR 0 = 0
0 OR 1 = 1
1 OR 0 = 1
1 OR 1 = 1

and that bitwise AND is :
0 AND 0 = 0
0 AND 1 = 0
1 AND 0 = 0
1 AND 1 = 1
)

Consider this OR :
--------------------
1001 = 9 ( 1 * 2^3   + 1 * 2^0 )
Say you want to set bit # 2 in this number made of 4 bits ie. you want to make
1001 ---> into 1101    (bit 3 would be the most significant ie. 2 power 3 or
2^3, bit 0 the least significant ie. 2 power 0 = 2^0 = 1)

The easiest way to do this is to use the number :
0100 (which is 4) - as it has ONLY BIT 2 set to "1".

and OR it to set BIT 2 ->
1001     OR'd with
0100 -----
1101 (see modulo-2 add below)

An AND is typically used to CLEAR (set to 0) a bit :
---------------------
Again, take the number 1001 (9 decimal).
Say you want to clear BIT 3 now :
You work out now where to go from here :
(ie. how to use a "mask" by using the one's complement)

1001   AND
0111    -----
0001    -> bit 3 is now "0".

Maybe one word of caution that we all occasionally can overlook :
--
It is general practice (qwell I do too) to "add" the bits in that you
want set to "1", rather than ORing.
As above :
1001 +
0100 ------
1101 -> 13 decimal - or (9 + 4) which is the same as 

It is important that you understand that you can only use "add" if the
symbols that represent the bits, are made up of
only 1 bit set to "1", and also that the same bit position can only be
used ONCE

Eg :

1001 OR
0001 -----
1001

BUT :
==
1001 +
0001 -----
1010    (10 decimal , 9 + 1)
If the intention was here to set BIT 0 to "1", the add actually caused
it to clear to "0" !!!!!!!!
Keep this in MIND !!...........


In your example before :
WDTCTL= WDTPW + WDTHOLD;

WDTCTL is a register, and WDPTW / WDTHOLD are "symbols" representing
certain bit positions.
If both these bits need to be set, then the statement as above will ONLY set the
WDTPW (Watchdog password) and WDTHOLD (Hold) bits to "1", the others
will be "0".

If you go :
WDTCTL= WDTPW;
after having done the statement above, then you are re-writing to that WDTCTL
register -
this time with only the WDTPW bit set - in effect the WDTHOLD bit has been set
to "0" now.........


Maybe this will give you a "kickstart", but you REALLY will need to
get a good book on C, and preferably
one that starts from the start - ie. the Binary number system, and how to handle
Boolean stuff.

I personally liked Herbert Schildt's "C, the complete reference"
a lot to get a good grasp on the basics
of "C" - but everyone to their own.....
Try and learn these things as you go along, and post questions on things
specific to MSP430 here that
you are stuck with.
Newcomers one day become a source of knowledge too - so have fun / good luck !!!


Kris






.



 



---------------------------------






The 2024 Embedded Online Conference