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

problem using epcs.c in SDK library

Altera_Forum
Honored Contributor II
1,002 Views

Hello,  

I have problem calling "nr_epcs_is_device_present()" function 

which I copied & pasted from epcs.c in SDK library. 

 

As far as I can see from the original source, 

The first thing it does in there is calling "nr_epcs_set_cs()" function 

to set chip select. 

 

After that, it is calling "nr_epcs_txchar(na_epcs_wren)" function 

to send WRITE ENABLE command. 

 

However, below loop in "nr_epcs_txchar(na_epcs_wren)" function continues forever. 

---------------------- 

while (!(na_epcs_controller->np_epcsstatus & np_epcsstatus_rrdy_mask)); 

---------------------- 

 

The base address of my epcs_controller is 0x00900000: 

 

typedef volatile struct{ 

int np_dummy[256]; // EPCS component fills lower 1k with code 

int np_epcsrxdata; // Read-only, 1-16 bit 

int np_epcstxdata; // Write-only, same width as rxdata 

int np_epcsstatus; // Read-only, 9-bit 

int np_epcscontrol; // Read/Write, 9-bit 

int np_epcsreserved; // reserved 

int np_epcsslaveselect; // Read/Write, 1-16 bit, master only 

int np_epcsendofpacket; // Read/write, same width as txdata, rxdata. 

} np_epcs; 

 

np_epcs* na_epcs_controller = (np_epcs*)(0x00900000); 

 

I am using NIOS II, and I heard that this legacy SDK is for NIOS. 

Is this the reason for my problem? 

 

If so, I would like to hear some hints as to modifying the above source.
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
285 Views

Hello, 

I solved my problem. 

 

It said on p12-4 of "Programming Model, Nios II Processor Reference Handbook" that  

"Altera does not publish the usage of the control and data registers. 

To access the EPCS device, you must use the HAL drivers provided by Altera." 

 

What I really wanted to do was to erase memory of EPCS, 

so I simply called alt_epcs_flash_erase_block() function of HAL api, and it worked. 

 

I guess the codes I refferred to at the beginning was for NIOS, not NIOS II..
0 Kudos
Reply