Altera_Forum
Honored Contributor
10 years agoTrigger and counter.
Hi,
I'm trying to implement a counter that counts down when it recieves a trigger pulse from the hardware (in this case, it's a short burst of AC, in the order of a few hundred µs), which keeps an LED on. I have no idea why my code isn't working, I'm pretty new to C programming. Any help greatly appreciated.if (trigger_reg == 1){ //goes to 1 when the AC signal reaches the trigger module threshold
int countdown = 10000000; //arbitrary value
while (countdown > 0){ //use this loop to keep the LED on longer than the trigger pulse, so the user can see it
green_leds=1;
countdown--;
}
} else {
green_leds=0;
} -N