FPGA, SoC, And CPLD Boards And Kits
FPGA Evaluation and Development Kits
5925 Discussions

de0-nano board / Nios2 troublemaker

Altera_Forum
Honored Contributor II
1,806 Views

Good evening, 

 

actually i m facing big troubles in making my leds blink with a nios processor. I followed all steps in the tutorial given in den development kit and have used the saved projects file given by the cd. But i am getting the same error over and over again. 

 

This is error: 

 

'PIO_LED_BASE' undeclared (first use in this function) hello_world.c /Hello_0 line 29 C/C++ Problem 

 

When i go along with my mouse over that x symbol which represent an error ,it also says: 

 

Multiple markers at this line (line 29) 

- each undeclared identifier is only reported once for each function it appears in 

- in expansion of macro 'IOWR_ALTERA_AVALON_PIO_DATA' 

- 'PIO_LED_BASE' undeclared (first use in this function) 

 

Thats the c-code im using which can also be found in the de0-nano board manuel (dvd or internet). 

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

 

int main() 

 

int count = 0; 

int delay; 

 

while(1) 

IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, count & 0x01); // error message X 

delay = 0; 

while(delay < 2000000) 

delay++; 

count++; 

 

 

return 0; 

---------------------------------------------------------------------------- 

 

I ve tested that nios_project with Quartus 13 which was also sent with the development kit. I ve encountered some strange issues during compliation like not creating an .elf file. Thats why i decided to make a new clean installation of the newest quartus version (15.0). But I am still not managing to run the code i ve provided above. 

 

Nios2 and its components were created by Qsys. I ve even checked the BASE_ADRESS in QSYS and in "system.h" against each other, but they re the same. I also checked the the name (LED_PIO_BASE) in "system.h" which is the right one im using in the ALTERA function. 

 

Actually i dont know what to do.
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
577 Views

Take a look at your system.h. If LED_PIO_BASE isn't there, look in QSYS. That name comes from the name of a compnent in QSYS called LED_PIO. If that isn't there or has a different name, the symbol LED_PIO_BASE won't be in system.h.

0 Kudos
Altera_Forum
Honored Contributor II
577 Views

Hello Galfoz, 

 

I ve checked that already. In QSYS the PIO was added as an output (8 bits width) and renamed as "led_pio". That entry can be found in "system.h". Here is a cutout. 

 

system.h 

------------------------------------------------ 

 

# define ALT_MODULE_CLASS_led_pio altera_avalon_pio 

# define LED_PIO_BASE 0x21020 

# define LED_PIO_BIT_CLEARING_EDGE_REGISTER 0 

# define LED_PIO_BIT_MODIFYING_OUTPUT_REGISTER 0 

# define LED_PIO_CAPTURE 0 

# define LED_PIO_DATA_WIDTH 8 

# define LED_PIO_DO_TEST_BENCH_WIRING 0 

# define LED_PIO_DRIVEN_SIM_VALUE 0 

# define LED_PIO_EDGE_TYPE "NONE" 

# define LED_PIO_FREQ 50000000 

# define LED_PIO_HAS_IN 0 

# define LED_PIO_HAS_OUT 1 

# define LED_PIO_HAS_TRI 0 

# define LED_PIO_IRQ -1 

# define LED_PIO_IRQ_INTERRUPT_CONTROLLER_ID -1 

# define LED_PIO_IRQ_TYPE "NONE" 

# define LED_PIO_NAME "/dev/led_pio" 

# define LED_PIO_RESET_VALUE 0 

# define LED_PIO_SPAN 16 

# define LED_PIO_TYPE "altera_avalon_pio" 

 

----------------------------------------------------- 

 

The name "led_pio" is fitting with the entry generated in the system.h. Case sensitivity does not seem to be considered cos nothing happened when i changed the function s argument which is called in the main(). Even putting the adress_base itself results into an error. 

 

Moreover there s only one warning in QSYS.  

------------------------------------------------------- 

Warning: nios_system.cpu: Nios II Classic cores are now superseded by improved Gen 2 cores. 

 

-------------------------------------------------------
0 Kudos
Altera_Forum
Honored Contributor II
577 Views

Identifiers in C are case sensitive. Rename the Qsys led_pio component to LED_PIO. Don't worry about the nios warning. It is just telling you that a newer NIOS is available. The error with IOWR_ALTERA_AVALON_PIO_DATA is because you haven't included the .h file for the GPIO core. I don't recall its name at the moment, but you should be able to find example code that uses it.

0 Kudos
Altera_Forum
Honored Contributor II
577 Views

is the problem still happens?

0 Kudos
Altera_Forum
Honored Contributor II
577 Views

This is a known eclipse bug. 

 

From the menu item 'Project' select 'C/C++ Index' -> 'Rebuild'
0 Kudos
Altera_Forum
Honored Contributor II
577 Views

is this problem happen sin window based or Linux based eds?

0 Kudos
Reply