This code blinks only red LED.
#include <msp430g2231.h>
void main()
{
P1DIR = 0x41;
P1OUT = 0;
while(1)
{
P1OUT = 0x01; // P1.6 on (green LED)
_delay_cycles(30000);
P1OUT = 0x00;
_delay_cycles(30000);
P1OUT = 0x40;
_delay_cycles(30000);
}
}
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
This code blinks only red LED.
#include <msp430g2231.h>
void main()
{
P1DIR = 0x41;
P1OUT = 0;
while(1)
{
P1OUT = 0x01; // P1.6 on (green LED)
_delay_cycles(30000);
P1OUT = 0x00;
_delay_cycles(30000);
P1OUT = 0x40;
_delay_cycles(30000);
}
}
I always said that for loops or __delay_cycles() isn't the proper way of doing delays. :)
But besides the fact that
doesn't really fit (0x01 and P1.6?), I don't see why it should fail. A look at the generated assembly code could could perhaps reveal what's going wrong here.Nakul Nagpal said:P1OUT = 0x01; // P1.6 on (green LED)
Greetings,
I stumbled on this post, and read your post. I am curious to know what you would suggest is the proper way of doing delays?
Best regards,
Jonathan Velez
Jonathan Velez said:proper way of doing delays?
If we talk about LED blinking delays then using timer interrupts with CPU sleep/wake-up is proper way. __delay_cycles() shall be used for short delays like I/O settle delays
**Attention** This is a public forum