Last active
October 27, 2020 18:10
-
-
Save trtg/4451982 to your computer and use it in GitHub Desktop.
msp430 launchpad sample code to blink LED 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Demo app to blink the red LED (LED1) on the TI Launchpad | |
//which is attached to P1.0 | |
//The green LED(LED2) is connected to P1.6 | |
#include <msp430g2553.h> | |
int main(void) { | |
volatile int i; | |
// stop watchdog timer | |
WDTCTL = WDTPW | WDTHOLD; | |
// set up bit 0 of P1 as output | |
P1DIR = 0x01; | |
// intialize bit 0 of P1 to 0 | |
P1OUT = 0x00; | |
// loop forever | |
for (;;) { | |
// toggle bit 0 of P1 | |
P1OUT ^= 0x01; | |
// delay for a while | |
for (i = 0; i < 0x6000; i++); | |
} | |
} |
Can you pls give an idea regarding interfacing Bluetooth with msp430
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
0x01 is in hex, in binary that's 0000 0001. So, what the line:
P1DIR = 0x01;
is saying is set bit 0 in port 1 direction register high. This sets the P 1.0 to an output pin.
If you said something like 2 or 3 the code wouldn't run because you are trying to output on P 1.0.
TI actually makes this a little easier by defined all the bits in header file so for example you could write this:
P1DIR |= BIT0;
Instead of:
P1DIR = 0x01;