- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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, PhaniendraLink Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi cris,
thanks for the reply. I have used IOWR/IORD macros and problem got solved.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page