Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

problem using epcs.c in SDK library

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.

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

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