Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12747 Discussions

what's wrong with my code?compile error

Altera_Forum
Honored Contributor II
1,125 Views

below is my code ,very simple,I compile it in nios IDE,not SDK,but I have created SDK with sopc builder.which header I need ?where can I find it ? In some sample ,I see "include "excalibur.h"",but some tell me this header was used in SDK ,not IDE? DO I need this file?when I put this file ,compile cann't find it too!thank very much! help me ! 

====================== 

# include <stdio.h># include "system.h" 

 

int main() 

 

na_timer1->np_timerperiodl = (short)(nasys_clock_freq & 0x0000ffff); 

na_timer1->np_timerperiodh = (short)((nasys_clock_freq >> 16) & 0x0000ffff); // Set timer running, looping, no interrupts 

na_timer1->np_timercontrol = np_timercontrol_start_mask+ np_timercontrol_cont_mask; 

 

return 0; 

=================== 

make -s all  

Compiling hello_world.c... 

../hello_world.c: In function `main&#39;: 

../hello_world.c:22: error: `na_timer1&#39; undeclared (first use in this function) 

../hello_world.c:22: error: (Each undeclared identifier is reported only once 

../hello_world.c:22: error: for each function it appears in.) 

../hello_world.c:22: error: `nasys_clock_freq&#39; undeclared (first use in this function) 

../hello_world.c:24: error: `np_timercontrol_start_mask&#39; undeclared (first use in this function) 

../hello_world.c:24: error: `np_timercontrol_cont_mask&#39; undeclared (first use in this function) 

make: *** [obj/hello_world.o] Error 1 

Build completed 

=======================
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
371 Views

You are trying to mix the legacy SDK with the HAL (the software environment used by the IDE). This won&#39;t work. 

 

The legacy SDK is not recommended for new projects. 

 

I suggest you look at using the macros within components/altera_avalon_timer/inc/altera_avalon_timer_regs.h which is the HAL way to do things. 

 

One more hint - if you are accessing the timer directly then you will need to start from an alt_main project as otherwise the HAL timer code will get in your way.
0 Kudos
Altera_Forum
Honored Contributor II
371 Views

wombat ,thank you very much!

0 Kudos
Reply