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

NIOS II CustomComponent Programming Problem

Altera_Forum
Honored Contributor II
758 Views

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;  

while(1)  

{  

*ledbaseaddr = 0xFF;  

//for(i=0;i<100;i++);  

*ledbaseaddr = 0x00;  

}  

 

http://www.alteraforum.com/forum/attachment.php?attachmentid=10302&stc=1 http://www.alteraforum.com/forum/attachment.php?attachmentid=10300&stc=1  

 

http://www.alteraforum.com/forum/attachment.php?attachmentid=10301&stc=1 http://www.alteraforum.com/forum/attachment.php?attachmentid=10302&stc=1  

 

 

 

 

Regards, 

Phaniendra
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
67 Views

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.
Altera_Forum
Honored Contributor II
67 Views

Hi cris, 

 

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