This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Infinite Loop

I am using the following code to blink a LED 10 times and then stop. But it goes on blinking even after 10 counts. please let me know where i have gone wrong in the code

#include <stdio.h>
#include <chipcon/hal.h>
#include <chipcon/cc1010eb.h>

#define Wait_Time 200

void main()
{
	int a=0;

	// Set Port 1 Bit 2 as O/P
	halSetPortBitDir(1, 2, POUT);

	// Initialise Counter
	while(a!=10) {
	// Wait period between blinks
	halWait(Wait_Time, CC1010EB_CLKFREQ);
	//Toggle LED
	halSetPortBit(1, 2, FALSE);
	a++;
	}
} //main

Parents
  • Hi Dan thanks for helping again. I tried putting a infinite loop just before the closing braces of main(), but the LED still blinks infdefinitely. I still cant figure out how to get this code fixed. please help

    #include <stdio.h>
    #include <chipcon/hal.h>
    #include <chipcon/cc1010eb.h>
    
    #define Wait_Time 200
    
    void main()
    {
    	int a=0;
    
    	// Set Port 1 Bit 2 as O/P
    	halSetPortBitDir(1, 2, POUT);
    
    	// Initialise Counter
    	while(a!=10) {
    
    	// Wait period between blinks
    	halWait(Wait_Time, CC1010EB_CLKFREQ);
    
    	//Toggle LED
    	halSetPortBit(1, 2, FALSE);
    	a++;
    	}
    
    	//A forever loop
    	for (;;);
    } //main
    

Reply
  • Hi Dan thanks for helping again. I tried putting a infinite loop just before the closing braces of main(), but the LED still blinks infdefinitely. I still cant figure out how to get this code fixed. please help

    #include <stdio.h>
    #include <chipcon/hal.h>
    #include <chipcon/cc1010eb.h>
    
    #define Wait_Time 200
    
    void main()
    {
    	int a=0;
    
    	// Set Port 1 Bit 2 as O/P
    	halSetPortBitDir(1, 2, POUT);
    
    	// Initialise Counter
    	while(a!=10) {
    
    	// Wait period between blinks
    	halWait(Wait_Time, CC1010EB_CLKFREQ);
    
    	//Toggle LED
    	halSetPortBit(1, 2, FALSE);
    	a++;
    	}
    
    	//A forever loop
    	for (;;);
    } //main
    

Children