Altera_Forum
Honored Contributor
14 years agogenral software problem
im writing a simple clock program for a niosII standard processor and i encountered this bug
in my main loop i have an infinite loop which updates all the seven segments(DE2 board) like
while(1) {
IOWR_ALTERA_AVALON_PIO_DATA(HEX2_BASE,sec_1);
IOWR_ALTERA_AVALON_PIO_DATA(HEX3_BASE,sec_10);
IOWR_ALTERA_AVALON_PIO_DATA(HEX4_BASE,min_1);
IOWR_ALTERA_AVALON_PIO_DATA(HEX5_BASE,min_10);
IOWR_ALTERA_AVALON_PIO_DATA(HEX6_BASE,hor_1);
IOWR_ALTERA_AVALON_PIO_DATA(HEX7_BASE,hor_10);
}
and the alt_u8 variables sec_1,sec_10 etc. are updated by a 100Hz interrupt(im running the processor on 50Mhz) when i run the program the seven segments are not updated :( but somehow this code works when i put a printf at the beggining of the while loop like
while(1) {
printf(" ");
IOWR_ALTERA_AVALON_PIO_DATA(HEX2_BASE,sec_1);
IOWR_ALTERA_AVALON_PIO_DATA(HEX3_BASE,sec_10);
IOWR_ALTERA_AVALON_PIO_DATA(HEX4_BASE,min_1);
IOWR_ALTERA_AVALON_PIO_DATA(HEX5_BASE,min_10);
IOWR_ALTERA_AVALON_PIO_DATA(HEX6_BASE,hor_1);
IOWR_ALTERA_AVALON_PIO_DATA(HEX7_BASE,hor_10);
}
then it works perfect.. i tried replacing the printf with a simple while loop delay but that doesnt work either. even when its not working the variables are updated timely and that means the process is running. but the code to update PIO_DATA works only when i put a printf what could be the cause of this? please help.. could it be because of an include file which the compiler uses beacuse of printf? or is it a simple matter of a delay? if so why doesnt introducing a simple delay fix it it also works when i put alt_printf