Altera_Forum
Honored Contributor
13 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 for the hell of it and the LED started blinking. Commeting out the print statement the behavior reverted back to what it was before. I don't see anything wrong with the code, so I doubt that is the problem. I am guessing my SOPC is messed up somewhere but I don't know where it could be. My SOPC has: 1 - pio (input) 1 - pio (output) JTAG interface onboard memory (RAM 8 kB) SD Card interface I am just learning VHDL, Nios, and SOPC, so right now this has been the most complicated system I have created thus far --------------------------------------------------------------- # include "System.h"# include "altera_avalon_pio_regs.h"# include <stdio.h># include "sys/alt_stdio.h" int main() { //alt_putstr("Hello from Nios II!\n"); int count = 0; int delay = 0; /* Event loop never exits. */ while (1) { IOWR_ALTERA_AVALON_PIO_DATA(LEDS_BASE, count & 0x01) ; delay = 0; while( delay < 10000) { delay++; } count++; //alt_putstr("Hello from Nios II!\n"); } return 0; }