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++

PIO LEDs always on

Altera_Forum
Honored Contributor II
1,906 Views

Hello, 

i have a NiosII sopc with a PIO[24] called LED. 

It is connected to the LEDs on the DE3 board. 

 

now i have a simple application : 

# define LED_BASE 0x00041010 // this is the base in the sopcbuilder .... int led_val = 0x0; IOWR_ALTERA_AVALON_PIO_DATA( LED_BASE, led_val); But the Leds are alway on.  

also when i change led_val to something else, nothing happens. 

 

and another question? 

why is a pointer to a pio alway implemented as char pointer??
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
523 Views

In sopc builder have you defined this pio as output only or bidir? If the latter, you need to set the direction bits for outputs. 

Check also in Quartus project if all connections are ok and signals are assigned to right pins. 

 

Regarding your question about pointers, using char is not mandatory. Infact you can use int when your pio is up to 32bits wide.  

Probably all samples use char because this is the native addressing mode of processor. 

 

Cris
0 Kudos
Altera_Forum
Honored Contributor II
523 Views

in sopc the LEDs are only output. 

In Quartus i have a Blockdiagram with the nios-system and outputs connected to the leds (in the pin assignment they are connected as well) the Blockdiagramm is set as top level entity. 

Another thing i tried is this: 

# define Buttons (volatile char *) 0x00040000# define LEDs (char *) 0x00041010 void main() { while (1) *LEDs = *Buttons; } 

Nothing happens... 

And another question, i have all unused pins set as input. there is a 7-segment display on the board which i do not use. but two of the lighsts are on.. how can this be?
0 Kudos
Altera_Forum
Honored Contributor II
523 Views

Hi goaran, 

Regarding the code you posted, I'd recommend this: 

- always use the defines in system.h instead of numeric addresses 

- always use IORD/IOWR macros to access pio registers; I had similar situations where the trick with pointers didn't work (I'm not sure why) 

 

Regarding the two segments always on, this depends where they are actually connected. If you use an input, the level is not well defined: a pull up/down on the signal can alter the signal level. I suggest you connect them to outputs or hardwire them to Vcc or gnd inside fpga. 

 

Cris
0 Kudos
Altera_Forum
Honored Contributor II
523 Views

If you don't use the IORD/IOWR macros, you need to remember to bypass any data cache.

0 Kudos
Altera_Forum
Honored Contributor II
523 Views

Ok, thanks 

 

I used the adreses from System.h and now its working. But i dont know really why. the Adresses i defined were the same as the base adresses in the SOPC builder.
0 Kudos
Reply