Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

MSP430 Launch pad Green LED (P1.6 ) blinking

Status
Not open for further replies.

chandrumcs

Newbie level 4
Newbie level 4
Joined
Jan 5, 2011
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,327
Hi Team,


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include  <msp430g2231.h>
 
 unsigned int i = 0;                         // Initialize variables. This will keep count of how many cycles between LED toggles
 
 
void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer. This line of code is needed at the beginning of most MSP430 projects.
                                            // This line of code turns off the watchdog timer, which can reset the device after a certain period of time.
 
  P1DIR |= 0x01;                            // P1DIR is a register that configures the direction (DIR) of a port pin as an output or an input.
 
 
                                            // To set a specific pin as output or input, we write a '1' or '0' on the appropriate bit of the register.
 
 
                                            // P1DIR = <PIN7><PIN6><PIN5><PIN4><PIN3><PIN2><PIN1><PIN0>
 
 
                                            // Since we want to blink the on-board red LED, we want to set the direction of Port 1, Pin 0 (P1.0) as an output
 
                                            // We do that by writing a 1 on the PIN0 bit of the P1DIR register
                                            // P1DIR = <PIN7><PIN6><PIN5><PIN4><PIN3><PIN2><PIN1><PIN0>
                                            // P1DIR = 0000 0001
                                            // P1DIR = 0x01     <-- this is the hexadecimal conversion of 0000 0001
 
 
 
  for (;;)                                  // This empty for-loop will cause the lines of code within to loop infinitely
  {
 
 
 
    P1OUT ^= 0x01;                          // Toggle P1 using exclusive-OR operation (^=)
 
                                            // P1OUT is another register which holds the status of the LED.
                                            // '1' specifies that it's ON or HIGH, while '0' specifies that it's OFF or LOW
                                            // Since our LED is tied to P1.0, we will toggle the 0 bit of the P1OUT register
 
 
 
    for(i=0; i< 20000; i++);                // Delay between LED toggles. This for-loop will run until the condition is met.
                                            //In this case, it will loop until the variable i increments to 20000.
  }
}




I used this for blinking RED LED P1.0. But I want to know how to glow the Green alone P1.6.

Please help


Regards,
Chandru
 
Last edited by a moderator:

Hello!
You should use P1OUT |= BIT6 (or P1OUT |= 0x40) because LED is on bit 6 of P1.
Dora.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top