Forum Discussion
Altera_Forum
Honored Contributor
14 years agoBlinking LED - stays on
I was trying to use NIOS to get an LED to blink over a set period. However, everytime the code is loaded the LED stays on. After a couple of hours of troubleshooting I added a print statement f...
Altera_Forum
Honored Contributor
14 years agoYour LED is probably blinking but you can't see it because the frequency is very high.
Adding the print call adds a delay greater than the while loop, so the frequency decreases to a "visible" range. Make this test: force the LED always on and you'll see a higher light intensity. While or for loops are a deprecated method to implement delays; besides the dependence on cpu speed, they are strongly affected by compiler optimizations. Some hard optimized compilers would even remove loops which have no functional side effect, like in your case. Using a timer would be a better solution.