I have a coursework for designing a state machine on the Microblaze microprocessor in C. The problem I have is that I have to change a certain picture. Let's say I press BTNL on the FPGA; I have to be presented with a landscape picture for 5 secs and after certain 3 secs I have to make that picture flash. In the meantime, the time 5s -> 0s has to be displayed on the 7-segment display. This is the case where the button has been detected and the flashing mode has to be displayed. The interrupt occurs every 0.004s and the microprocessor's clock is 100MHz.
for(j=0; j<=5secs; j++)
{
if(j>3secs)
{
if(counter == sec){
counter=0;
if(temp==white){ //white background
temp=background;
}
else temp=white;
}else counter++;
XGpio_DiscreteWrite(®ION[4],1,temp);
}
else XGpio_DiscreteWrite(®ION[4],1,temp);
if(j==5secs)
states = IDLE;
}
My main problem is with displaying the number on the 7-segment display. When I place the displayNumber()
function in the case, the whole thing just freezes once it goes to the displayNumber()
line. I know the nested for
loops cost a lot of time and energy and I think this might cause the problem, but I cannot find a working solution. Any thoughts or advice are really appreciated.
Another thing is that I tried with a flag, but because of the interrupt handling it doesn't work.
EDIT: I am not trying to get a copy/paste solution of my problem. The whole thing is quite massive, I mean verilog project along with the files for the other functions done in c. I didn't expect you to run the code and reproduce the whole thing, because I had been provided the Verilog project by the school, so you have to generate a bitstream and then upload and run the whole thing on the board. I am here just looking for a suggestion about How would you improved this, have you encountered such behaviour with FPGAs, any ideas.
Thanks for the time spent to read the question!