-
Port Initialization
12/11/2018 at 19:57 • 0 commentsNow lets look at how to use the pins for output.
There are many ports on the MSP430 (varies on version) , for example PORT-1 ( P1.0 to p1.7 ) &
PORT-2 ( P2.0 to P2.7 ).
#include <msp430.h> /** * main.c */ void main(void) { WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer P3DIR=0xFF; // P3DIR=0x00; P6DIR=0xFF; P4DIR |=0x00; P4REN |=0xFF; P4OUT |=0xFF; }
P3DIR |=0x00 tells us that the whole of PORT-3 is initialized to take inputs.
P3DIR |=0xFF tells us that the whole of PORT-3 is initialized to give outputs.
P3DIR |=0x01 only the pin P3.0 is initialized to output in PORT-3.
This follows a Hexadecimal Port mapping.
The Major advantage with the higher versions of MSP430 are , they have inbuilt Pull -Up or Down resistors, so no need to connect externally.
P4REN |=0xFF , this indicates that the pins of PORT-4 have their pull up/down resistors enabled.
TO select them between Pull UP or Pull DOWN, the instruction P$OUT |=0xFF is used.
If 0xFF is used they configure as Pull UP resistors and if 0x00 they configure as Pull DOWN.
-
INSIGHTS
12/11/2018 at 19:39 • 0 commentsLet's Begin!
Initialize the watchdog timer to OFF state using the required password for the watchdog timer
(It helps to keep check of infinite loops , keeping the processor safe).
#include <msp430f5529.h> // or #include <msp430.h> /** * main.c */ int main(void) { WDTCTL = WDTPW | WDTHOLD; // The HOLD bit is 1 return 0; }
WDTCTL is the watch dog timer control register.
One of the Bit is WDTHOLD , this can be accessed through a specific password value WDTPW.
From WDTHOLD one can control ON and OFF of a Watchdog timer.