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.
12409 Discussions

NIOS II CustomComponent Programming Problem

Honored Contributor II

Hi all, 


I have created a LED register in vhdl and created qsys component out of that. Connected it to the nios processor as shown in below images. Created NIOS project and when I am trying to run the code the register is not updated. But if I access with the base address of the memory map generated, it is getting updated. Kindly someone let me know what could be the issue. 


I included system.h and written a simple program to edit the led base register. From memory I am able to access and blink led. But from C program I am not able to control it. 

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

int main()  


unsigned int* ledbaseaddr =(unsigned int *) LEDREG_0_BASE;  

// unsigned int i;  



*ledbaseaddr = 0xFF;  


*ledbaseaddr = 0x00;  







0 Kudos
2 Replies
Honored Contributor II

I guess this happens because Nios uses byte addressing, while C code unsigned int* forces 32bit addressing. Try to cast with unsigned char* . 

Anyway the best way to access qsys component registers is through IOWR/IORD macros, which automatically take care of matching the device bus size.
Honored Contributor II

Hi cris, 


thanks for the reply. I have used IOWR/IORD macros and problem got solved.