Jump to content

Using the reset pin to power up/down/reset

Recommended Posts

Hi all,

This is a small program to toggle the launchpad LEDs with the RESET pin on your favorite micro.

It can also be used to put your system into sleep mode, while retaining the ability to reset the msp.


If you hold the reset button down for five seconds or more, the micro will reset.

If you hold it for under five seconds, the green LED will toggle once.


#include "msp430g2211.h"

#define LED1_TOGGLE P1OUT ^= BIT0
#define LED1_ON P1OUT |= BIT0
#define LED1_OFF P1OUT &= ~BIT0
#define LED2_TOGGLE P1OUT ^= BIT6
#define LED2_ON P1OUT |= BIT6
#define LED2_OFF P1OUT &= ~BIT6

void main(void) {
IE1 |= WDTIE+NMIIE; // Enable the NMI and WDT interrupts
P1OUT = 0xFF;
P1DIR = 0x77;
P1REN = 0x88;
P2DIR = 0;
P2SEL = 0;

#pragma vector = WDT_VECTOR
__interrupt void NMI_enable(void){
IE1 |= NMIIE; // enable the non-maskable reset pin interrupt,
}				  // seems it is turned off after each use

#pragma vector = NMI_VECTOR
__interrupt void powermode(void){

//>>>>switch BIT7 from what ever it is usually used for, connect it to RESET<<<<

char time;
for(time=0; time<50 && !(P1IN & BIT7); time++){ // poll BIT7 during the loop
	LED1_TOGGLE; // toggle the red launchpad LED
if(time>48){ // if held down for five seconds
	WDTCTL = time;	// restart system
else LED2_TOGGLE; // toggle the green launchpad LED
IFG1 &= ~WDTIFG+NMIIFG; // clear the NMI and WDT interrupt flags

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...