I am trying to use the following code for blinking LED on CC2530, it would be great if someone could tell me what I am doing wrong? I know this is basic stuff but I cannot figure out what I am doing wrong! The LED is mapped to port 0 and 7th pin (06).
I am using IAR to debug the program, when I run it in steps, LED do toggle! but when I run it without stopping, LED just glows, I thought it might be because of delay being miniscule, but no matter what value of delay I use, it just glows without blinking.
#define LED1_MASK 0x40
#define LED1_PIN P0_6
int main()
{
P0SEL &= ~(LED1_MASK);
P0DIR |= (LED1_MASK);
while(1)
{
//clock_delay(10000); // i tried running empty for loops and NOP for loop too.
LED1_PIN = 1;
for(int i = 0; i< 1000; i++)
{
for(int j = 0; j< 1000; j++)
{
ASM(nop);
}
LED1_PIN = 0;
}
EDIT: This is the actual program I am running, I made a mistake while pasting before (wasn't changing value of LED_PIN in the code). I am sorry for the trouble.
Best Answer
Based on my vast experience, I think you are not blinking the LED. Change second
LED1_PIN = 1; to
LED1_PIN = 0; and wait for some time.Edit: The waiting time after the LED has turned off is so less to perceive it as off by the human eye. As @peter pointed, the delay can be made equal and huge between both turn on and turn off code segments. Congrats ! You got your code working.