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

C help with read/write to Qsys component

Altera_Forum
Honored Contributor II
1,415 Views

I am using the Data Pattern Generator/Checker IP in a Qsys file and trying to configure it via a NIOS. However, I am having some trouble. I am using IOWR_32DIRECT() and IORD_32DIRECT() to write and read configuration data but I am not getting correct data when I try to enable the IP cores. 

 

I've attached the Qsys, C code, and the terminal output. I'd like someone to review it and let me know if there is something in the code that would cause the issue. The puts and printf works but the IORD's don't give the correct values. I checked the Qsys and it looks like everything is connected up correctly. 

 

Thanks for your help. 

 

 

 

hello_world_small.c 

 

// "Small Hello World" example. 

# include "sys/alt_stdio.h"# include "system.h"# include <io.h># include "os/alt_syscall.h"# include <unistd.h> 

 

int alt_main() 

unsigned int PRBS15 = 0x2; 

unsigned int ENABLE = 0x1; 

 

alt_putstr("Hello from Nios II!\n\n"); 

usleep(500000); 

 

alt_putstr("Begin configuration of Pattern Generator\n\n"); 

usleep(500000); 

 

alt_putstr("Setting pattern to PRBS15...\n"); 

usleep(500000); 

 

 

IOWR_32DIRECT(DATA_PATTERN_GENERATOR_0_BASE, 4, PRBS15); 

usleep(500000); 

alt_printf("The value read from Generator is %x\n", IORD_32DIRECT(DATA_PATTERN_GENERATOR_0_BASE, 4)); 

usleep(500000); 

 

IOWR_32DIRECT(DATA_PATTERN_CHECKER_0_BASE, 4, PRBS15); 

usleep(500000); 

alt_printf("The value read from Checker is %x\n\n", IORD_32DIRECT(DATA_PATTERN_CHECKER_0_BASE, 4)); 

usleep(500000); 

 

 

 

alt_putstr("Enabling pattern generator...\n"); 

usleep(500000); 

 

 

IOWR_32DIRECT(DATA_PATTERN_CHECKER_0_BASE, 0, ENABLE); 

usleep(500000); 

alt_printf("The value read from Checker is %x\n", IORD_32DIRECT(DATA_PATTERN_CHECKER_0_BASE, 0)); 

usleep(500000); 

 

 

IOWR_32DIRECT(DATA_PATTERN_GENERATOR_0_BASE, 0, ENABLE); 

usleep(500000); 

alt_printf("The value read from Generator is %x\n\n", IORD_32DIRECT(DATA_PATTERN_GENERATOR_0_BASE, 0)); 

usleep(500000); 

 

return 0; 

 

 

 

terminal output 

 

 

Hello from Nios II! 

 

Begin configuration of Pattern Generator 

 

Setting pattern to PRBS31… 

The value read from Generator is 8 

The value read from Checker is 8 

 

Enabling pattern generator… 

The value read from Checker is 0 

The value read from Generator is 0 

 

End
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
442 Views

Hi, 

 

 

--- Quote Start ---  

Setting pattern to PRBS31… 

The value read from Generator is 8 

The value read from Checker is 8 

 

Enabling pattern generator… 

The value read from Checker is 0 

The value read from Generator is 0 

--- Quote End ---  

 

Maybe the eclipse project is corrupted, Delete and create a new project and check. 

Are you expecting output like below 

 

--- Quote Start ---  

Setting pattern to PRBS31… 

The value read from Generator is 2 

The value read from Checker is 2 

--- Quote End ---  

 

 

Are you trying to check the Enable bit? 

Then it's should have a value whose LSB bit 1.Example. 

 

--- Quote Start ---  

Enabling pattern generator… 

The value read from Checker is 2b 

The value read from Generator is d 

--- Quote End ---  

 

 

Let me know if this has helped resolve the issue you are facing or if you need any further assistance. 

https://www.alteraforum.com/forum/attachment.php?attachmentid=15472  

Best Regards, 

Anand Raj Shankar 

(This message was posted on behalf of Intel Corporation)
0 Kudos
Reply