Jump to content
Sign in to follow this  
teoah

Weird CCS problem with #define

Recommended Posts

You can reset the watchdog by:

 

   WDTCTL  |= WDTCNTCL

 

I don't think that would work, as to write to the WDT+, you need to specify the password, or any write attempts simply get discarded. Thus the WDTPW in my code snippet.

 

I could be wrong though.

 

EDIT: Yeah, page 10-8 of the user's guide (same page you referenced, bluehash) states that "WDTPW...must be written as 05Ah, or a PUC will be generated", meaning that if the WDTPW isn't included in any command to WDTCTL, the WDT+ is reset to power-on conditions--reset the program at counter overflow.

Share this post


Link to post
Share on other sites
Yeah, page 10-8 of the user's guide (same page you referenced, bluehash) states that "WDTPW...must be written as 05Ah, or a PUC will be generated", meaning that if the WDTPW isn't included in any command to WDTCTL, the WDT+ is reset to power-on conditions--reset the program at counter overflow.

 

Yes, you need to send the password down to.

10.2.2 Watchdog Mode

After a PUC condition, the WDT+ module is configured in the watchdog mode

with an initial 32768 cycle reset interval using the DCOCLK. The user must

setup, halt, or clear the WDT+ prior to the expiration of the initial reset interval

or another PUC will be generated. When the WDT+ is configured to operate

in watchdog mode, either writing to WDTCTL with an incorrect password, or

expiration of the selected time interval triggers a PUC. A PUC resets the WDT+

to its default condition and configures the RST/NMI pin to reset mode.

 

So, to reset the watchdog:

WDTCTL  |= 0x5A00;       //Set the password 
WDTCTL  |= WDTCNTCL;  // Reset 

Share this post


Link to post
Share on other sites

Thanks both of you for clearing up the watchdog timer question! :)

 

Well, You have to tell the controller how you wish to use the pin. If you want to connect it to an LED, you configure it as an output. If you connect a switch to the pin, you need to configure it as an input. Its not going to work if you connect an LED to the pin, and its configured as an input.

You configure a pin in one step at the start of the program. This allows the controller to change its internal gate structure to accept a signal(input) or apply a signal(output):

Set the direction ( input or output ) of the pin in the direction register. An example of an output pin:

P1DIR |= BIT0

 

Now then, in your main program you may read or write to the pin. An example of writing to the pin:

P1OUT |= BIT0;

 

Ah ok. I'm starting to understand. So when I do, for example,

P1DIR |= BIT0

It translates into an instruction (BIS.B from what I see?) which sets the first bit of the Port 1 direction register, which then sets the first I/O pin on Port 1 as output, using logic gates.

 

Then, when I do

P1OUT |= BIT0

I set the output on the first I/O pin on Port 1 to high, which basically means to let the current go through? (ie. turn on the LED if there's an LED there).

 

So then, is "writing to a pin" the same thing as "setting the output to high or low" ?

 

Two more questions:

- So each pin that can both be an input and an output has two different circuits to toggle between the two modes?

- What are pullup/pulldown resistors? Or when are they supposed to be enabled?

- What's PUC?

Share this post


Link to post
Share on other sites
I set the output on the first I/O pin on Port 1 to high, which basically means to let the current go through? (ie. turn on the LED if there's an LED there).

Yes.

 

So then, is "writing to a pin" the same thing as "setting the output to high or low" ?

Exactly!

 

So each pin that can both be an input and an output has two different circuits to toggle between the two modes?

Yes.

 

What are pullup/pulldown resistors? Or when are they supposed to be enabled?

I'll also let you google this. If you are unable to get it, post back.

 

What's PUC?

Power Up Clear

Share this post


Link to post
Share on other sites
So, to reset the watchdog:

WDTCTL  |= 0x5A00;       //Set the password 
WDTCTL  |= WDTCNTCL;  // Reset 

bluehash: I think it needs to be set as a single 16-bit value. The password is the first 8 bits and the function is the lower 8 bits. i.e.:

WDTCTL  |= (0x5A00 + WDTCNTCL);
//(or you could use (0x5A00 | WDTCNTCL), as I learned earlier.  

Your code would send the password, but no function (or the "0" function, if there is one), then the reset function with no password, which would be ignored.

 

-Doc

Share this post


Link to post
Share on other sites
No documentation on that, but I would do it your way.

I knew I'd seen it somewhere... MSP430x2xx Family User Guide, section 10.2:

WDTCTL is a 16-bit, password-protected, read/write register. Any read or write access must use word instructions and

write accesses must include the write password 05Ah in the upper byte. Any write to WDTCTL with any value other than 05Ah in the upper byte is a security key violation and triggers a PUC system reset regardless of timer mode.

-Doc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×