Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12367 Discussions

Pointing to Interval Timer Nios

Honored Contributor I


I am new to Nios and was wondering if someone could help me figure out what I am doing wrong pointing to the interval timer. I have read the Embedded Peripherals section on it multiple times and it has not helped. I used pointers as opposed to using IRQs, becuase thats how the LED example was, I am trying to eventually create a program that has a Real time sampling interval, because I will be adding an ADC next. I have been adding the components one at a time to understand their functionality and properly use them. If I have a wrong approach for the leads with pointers please correct me as well. I had the leds working with a counter. I was trying to just check and reset the status register for the interval timer so that I could have it update the leds on the timers cycle. I know there are code examples, but writing my own and working through it is the best way to learn, I just got stuck and wasn't sure why this approach was not working when it did for the leds. Thanks a bunch 

# include <stdio.h># include <system.h> int main() { int* led= (int *)PIO_0_BASE; // air pio pins into the regulator int* timer_status= (int *)TIMER_0_BASE; int count=0; *led=0x3; while(1) { if(*timer_status==0x1) { *timer_status=0x0; if (count==0) { *led=0x3; //*air=0x3; count=1; } else if (count==1) { *led=0x2; count=2; } else if (count==2) { *led=0x1; count=3; } else if (count==3) { *led=0x0; count=0; } } } return 0; }
0 Kudos
1 Reply
Honored Contributor I

So I did a lot of reading and learned a bunch about the HAL which didn't help me. I found out that to fix my code I have to keep telling the counter to start after it finishes. Is there a way to make it just keep recounting in Platform designer/Qsys? I thought that was the default setting already.