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

PIO Bitwise operation

Altera_Forum
Honored Contributor II
1,276 Views

Hallo, 

 

What is the best way to perform bit wise operation to clear or set specific bits on Nios II PIO port? 

 

An example 

 

CTRL_PORT = CTRL_PORT | (1 << CTRL_CS) | (1 << CTRL_RDE) | (1 << CTRL_WR); 

CTRL_PORT = CTRL_PORT & ~(1 << CTRL_ALE); 

 

 

Where 

# define CTRL_CS 0# define CTRL_RST 1# define CTRL_RDE 2# define CTRL_WR 3# define CTRL_ALE 4
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
113 Views

When you instantiate a PIO in Qsys, you can optionally enable the single bit clear/set feature. 

You can then use the IOWR_ALTERA_AVALON_PIO_SET_BITS / IOWR_ALTERA_AVALON_PIO_CLEAR_BITS macros. 

Enabling this option you spare the instructions required to read the actual pio status and masking the existing bits.
Altera_Forum
Honored Contributor II
113 Views

Can you give me an example based on the code that I posted before?

Altera_Forum
Honored Contributor II
113 Views

Find it thanks.

Reply