Saturday 18 November 2017

MSP430G2553 – LED/Blinky

Blinking LED is similar to "Hello World" for an embedded engineer. I started using launchpad as a part of my MSc. project and have been experimenting with it since then. As there are many blogs and websites that assist a beginner or a pro alike, I'll mention all that I referred (wherever relevant).

The best blog to get started with MSP430 would be : MSPSCI Blog

This blog covers all the basics required to get started with the development process. I have used MSP430G2553 microcontroller on a launchpad board for this project.

Hardware: Although, there is an on-board LED, I have used an external one and have connected everything on a breadboard. (Picture will be added soon).

Code: There is a default project called Blink.c (CCS), you may use that or the below mentioned code.
 
#include<msp430.h>

void main(void)

{

WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

P1DIR |= BIT0; // Set P1.0 to output direction

for(;;)

{

volatile unsigned int i; // volatile to prevent optimization

P1OUT ^= BIT0; // Toggle P1.0 using exclusive-OR

__delay_cycles(100000); //delay of 10000 cycles at 1MHz

}

}

No comments:

Post a Comment