Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21594 Discussions

Epcs4 interface problem

Altera_Forum
Honored Contributor II
1,959 Views

Hi, 

I am using EPCS4SI8N through SPI interface to a microcontroller to write and read data. Right now I have done the connections accordingly but have problems with read and write to the serial EEPROM.  

I am not getting any response for any of the opcodes. The logic looks simple but dont know where I am going wrong. 

 

Thanks in advance!
0 Kudos
14 Replies
Altera_Forum
Honored Contributor II
1,205 Views

Hi, 

is the hold pin high (pin 7)? You may try to read identifier (command 20h). If you are not sure about the SPI protocol, you may have a look at the data sheet of another Flash e.g. M25P32. 

Regards
0 Kudos
Altera_Forum
Honored Contributor II
1,205 Views

Hi, 

Yeah the hold pin is high connected to 3.3V. I think my SPI protocol is correct since it worked fine with SD card.  

 

I have done the following steps: 

 

- pull CS low 

- send WREN(0x06) 

- pull CS high 

- delay(); 

- pull CS low 

-send WRITE(0x02) 

- send address 1st byte (MSB) 

- send address 2nd byte 

- send address 3rd byte (LSB) 

- send data 

- pull CS high 

- delay(); 

 

Even for read its done in a similar way but using read opcodes. 

 

 

Thanks!
0 Kudos
Altera_Forum
Honored Contributor II
1,205 Views

> - pull CS low 

> - send WREN(0x06) 

> - pull CS high 

> - delay(); 

 

propose to insert the following lines, to check that the Flash "wants" to talk with you :-) 

 

- pull CS low 

- send RDSR (0x05) 

- read 1 byte --> shout be 0x02 (=Write Enable Latch is set) 

- pull CS high 

 

Regards, 

Heiko
0 Kudos
Altera_Forum
Honored Contributor II
1,205 Views

Hi, 

Yeah after I send the WREN, I have done what you have told. 

 

do{ 

pull CS low 

send 0x05 

read from eeprom 

pull CS high 

while(!(read & 0x02)) 

 

So I send it many times until i receive 0x02. But I am receiving 0 from the eeprom. 

 

Thanks!
0 Kudos
Altera_Forum
Honored Contributor II
1,205 Views

Hi, 

so best is realy to start with the indentifier command (0x20).  

 

- CS low 

- write 0x20 

- read 3 bytes 

- CS high 

 

I assume you'll get zeros again. If so, you need to check with a scope the right order of the bits, clock edges, etc. Best is to compare it with the drawings e.g. in the data sheet of M25P32. 

 

Regards, 

Heiko
0 Kudos
Altera_Forum
Honored Contributor II
1,205 Views

Hi, 

I have done what you told but I get 255 from the eeprom. I have just sent 0x20 and am reading 3 bytes, nothing else. Is that right? 

 

Thanks!
0 Kudos
Altera_Forum
Honored Contributor II
1,205 Views

Hi, 

you have a problem with your interface as 255 is definitly wrong. You should get something like 0x01, 0x02. 0x12. You may download the data sheet of S25FL004A and compare with figure 9.3. Is your speed too high? 

Regards, 

Heiko
0 Kudos
Altera_Forum
Honored Contributor II
1,205 Views

Hi, 

I shall check with that datasheet. I have set my SPI clock to 5MHz. Initially it was 2MHz but I have changed it. Is that okay? 

 

Thanks!
0 Kudos
Altera_Forum
Honored Contributor II
1,205 Views

Hi, 

the slowest device should run with at least 25MHz, but check the data sheet I mentioned. 

Regards, 

Heiko
0 Kudos
Altera_Forum
Honored Contributor II
1,205 Views

Hi, 

My MCU bus frequency is 20MHz. So I can assign 10MHz for SPI. Well is that okay? 

 

Thanks!
0 Kudos
Altera_Forum
Honored Contributor II
1,205 Views

10MHz is less than 25MHz - hence it is OK :-)

0 Kudos
Altera_Forum
Honored Contributor II
1,205 Views

Hi, 

255 probably means High Impedance. you can check it by pulling it down. are you sure that the IC is properly powered?
0 Kudos
Altera_Forum
Honored Contributor II
1,205 Views

Hi, 

By pulling it down u mean...connect a resistor from that line to ground? 

 

Thanks!
0 Kudos
Altera_Forum
Honored Contributor II
1,205 Views

 

--- Quote Start ---  

Hi, 

By pulling it down u mean...connect a resistor from that line to ground? 

 

Thanks! 

--- Quote End ---  

 

 

yes, if it's a real 1 then you shoudn't have any problem. but if it's Z ( that is shown as 1 ) you will get 0. right?
0 Kudos
Reply