running AT25F2048 with psoc5

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

Hi every body.I use an electronic board that contain at25f2048(eeprom).So i want to connect psoc5lp prototype kit with this eeprom chip.I want to know how can i use eeprom component in psoc creator to write and reed in my chip?

   

tanks for your attention and supporting...

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

EEProm component is for the PSoC5 internal eeprom (2kB). The emfile component allows for os-compatible sd cards.

   

All eeprom is prone for power-losses while programming is in progress. A power supply that can overcome some 20ms line losses should be considered.

   

 

   

Bob

View solution in original post

0 Likes
32 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Datasheet of at25f2048 tells that it uses an SPI interface. So drop an SPI Master component onto your topdesign and write some lines of code to access it as required.

   

 

   

Bob

0 Likes
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

Tanks dear Bob.why i cant use eeprom component or emfile in psoc creator to reed or write on at25f2048?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

EEProm component is for the PSoC5 internal eeprom (2kB). The emfile component allows for os-compatible sd cards.

   

All eeprom is prone for power-losses while programming is in progress. A power supply that can overcome some 20ms line losses should be considered.

   

 

   

Bob

0 Likes
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

Hi MR Bob Marlowe.i cant runnig and get RDID(chip id).so please see my code and tell me why it is not working?

   

please see my code here :

   

#include <project.h>
#include <stdio.h>

   

#define RDID 0b00010101
uint8 readid=0u;
int main()
{
    
    CyGlobalIntEnable; /* Enable global interrupts. */
    
    UART_Start();
    SPIM_Start();    
    
    for(;;)
    {
        
        //SPIM_WriteByte(RDID);
        SPIM_WriteTxData(RDID);
        while(readid==0u)
        {
            readid=SPIM_ReadRxData();
            //readid=SPIM_ReadByte();
        }
        UART_PutChar(readid);
        CyDelay(500u);
        UART_PutChar('\n');
        
        readid=0u;
        CyDelay(5000u);

   

    }
}

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You read from SPIM without checking / waiting before a byte has been received. Use API SPIM_GetRxBufferSize() to see how many bytes there are. UART_PutChar() will not write ASCII chars, I would suggest using sprintf() to convert to a readable string.

   

For every bit (byte) the SPI interface gets, one bit (byte) is returned immediately. When the very first byte is sent, the interface does not "know" yet what to answer, so a dummy byte is returned which should be skipped.
SPI has no read command, so you must send dummy bytes to retrieve the information wanted.
A pitfall is the select line, which is automatically taken low when a byte is sent. When the buffer is empty it is taken high again. This can lead to interface errors when the byte sequence is not provided fast enough resulting in ss-line glitches.

   

 

   

Bob

0 Likes
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

Sorry... I cant understand what should i do for your explanation.can you give me any example for correct send and receive data in spi mode?

   

tank you...

0 Likes
lock attach
Attachments are accessible only for community members.
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

See this example...

   

 

   

Bob

0 Likes
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

tankyou dear Bob...

0 Likes
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

Hi Bob

   

I can get chip ID from below code but i cant READ or Write.I cant find where is my mistake and how can i do it.help me plz?

   

        SPIM_ClearTxBuffer();
        SPIM_ClearRxBuffer();

        SPIM_WriteTxData(RDID);

   

        SPIM_WriteTxData(RDID);
        
        while (!(SPIM_STS_SPI_DONE | SPIM_STS_SPI_IDLE))
        
        size=SPIM_GetRxBufferSize();
        sprintf(a,"size=%3d",size);
        UART_PutString(a);
        UART_PutChar('\n');
        
        while(SPIM_GetRxBufferSize())
        {
            readid=SPIM_ReadRxData();
            //readid=SPIM_ReadByte();
        }
        sprintf(a,"readid=%3d",readid);
        UART_PutString(a);
        CyDelay(500u);
        UART_PutChar('\n');
  

0 Likes
lock attach
Attachments are accessible only for community members.
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

Please see my code here and tell me my question : when i send write register and then send every command that i send back 255.is it worked or not?

   

then i cant read byte in at25f2048.just i see 255.is there any body that know what is my mistake?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Can you please post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

ok.this is my project...

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You are not following the scheme with the CS-line. The signal is continuosly driven low by your hardware design. Remove the "Logical 0" component, the connection, uncheck the "Hardware connection" in the pin and finally set the  initial drive state to High. Now you can manage the CS state.

   

The CS should be taken low just before the transmission starts and must be taken high again when the transmission has finished which can be checked by the number of bytes received in the buffer.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

tankyou Bob for your explanation.I changed cs confige as you said.but i just get chip id correct and can not write or read on at25f2048.what is my problem?is there any mistake?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

        while (!(SPIM_STS_SPI_DONE | SPIM_STS_SPI_IDLE))

   


You are testing bits, but not the status of the SPIM. Use SPIM_ReadTxStatus() & (SPIM_STS_SPI_DONE | SPIM_STS_SPI_IDLE)

   

Set the Heap size to 0x200 when using sprintf

   

 

   

Bob

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Do not keep CS low for a very long time as printing to UART. Define your transaction, get the bytes and finish. Do not send multiple commands without de-asserting CS

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

Bob I changed heap size to 0x200 and I did your explanation.but it is not worked again.I am very sad that i cant running eeprom.what is your suggestion,what is my problem solution?

0 Likes
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

MR Bob Marlowe do you have telegram or whatsapp to connect and speak faster?

0 Likes
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

I can not solved my problem with AT25F2048 yet. what is my mistake in program???I think my problem is spi interfacing because i observation code to read and write...it there any mistake?how can i understand???

   

please help me...

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Use

   

        CS_Write(0);
        SPIM_WriteTxData(RDID); // Read ID command
        SPIM_WriteTxData(0x00); //  Dummy write to get result
        while (!(SPIM_ReadTxStatus()&SPIM_STS_SPI_IDLE)) { } // Wait for complete transfer
        CS_Write(1); // End of transaction
        SPIM_ReadRxData();   // Read off first unsusable byte
        readid=SPIM_ReadRxData();  // Read ID

   

Change the other parts accordingly.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

thank you dear Bob.i changed code but it  is not diffrent.so i just get RDID correct and write or read opration was nor worked...

   

Is my TopDesign correct or not?and how can i do to find mistakes?

   

is my circuit correct?(attached in forum)

   

tanks for your attention...

   

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

When the readID works, concentrate on the next step only. Lesser to change and fewer to observe.

   

The CS de-selection might be too short: the time between writing a 1 and starting the next transaction.

   

When readID works, you can write a function that reads one byte from a given register making it easier to expand the project. Do not forget to get the device out of sleep mode.

   

A bug is

   

        SPIM_WriteTxData((char)(addr>>8));

   


a 8bit value >> by 8 will always result in zero.

   

 

   

Bob

0 Likes
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

TopDesign and spi setting has not problem? and i set 1 mil second delay time after per CS de-selection changes but just RDID worked.

   

even i just send read-register to read 1 byte from memory but it is not worked.

   

I am very confused... excuse me for flooding forum...

0 Likes
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

in LPC2138 and AVR microcontroller for working with AT25F2048 should send address of memory byte to read or write on them as bellow:

   

addr>>8 and then sending just : addr

   

so you think it is wrong?how can i correction memory address byte?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

?how can i correction memory address byte? Define "address" as uint16 (and not uint8)

   

 

   

Bob

0 Likes
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

I use ready example from this site and change psoc3 to psoc5 and i dont change any other parameters, but Eeprom not read or write.

   

below is example address link :

   

http://www.cypress.com/knowledge-base-article/spi-eeprom-interface

   

what do you think about my problem.i khow that i have a mistake.but i cant find what is it!!!???

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

The example looks quite different to your project. I would like to see the changes I suggested and the results. Sorry, but I do not have got an SPI EEPROM to test/check the project. Helpful for you could be a logic analyser to check the communication.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

This is running eeprom with psoc5 file in cypress example.i just changed psoc3 to psoc5 and change pin on port2.and replace uart with lcd and use dummy byte as you said to working...but it is not worked...just give a chip id .and any other function (write&read)back zero....

   

Please tell me what can i do to solved problem???

   

Tankyou for your attention...

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

This was correct to read the ID from eeprom

   

        SPIM_WriteTxData(RDID);
        SPIM_WriteTxData(0x00);        
        while (!(SPIM_ReadStatus() & SPIM_STS_TX_FIFO_EMPTY)) {}

   

        SPIM_ReadRxData();   // Read off first unsusable byte
        readid=SPIM_ReadRxData();  // Read ID

   

The second write was needed to get an answer (ID) back from device. On all other of your acesses you again write an additional byte without expecting a value back. Read google's explanation how SPI works, I think it is not quite clear for you.

   

 

   

Bob

0 Likes
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

I am changed your explenation in my project.but it is not worked .when i read every write data on spi,get zero for reply.below is out result for status of any command operation :

   


AT25F2048...
readid= 31
STATUS_WREN=  0
STATUS_PROG=  0
STATUS_addr=  0
STATUS_data=  0
STATUS_READ=  0
STATUS_addr=  0
STATUS_data=  0

   


readid= 31
STATUS_WREN=255
STATUS_PROG=255
STATUS_addr=  0
STATUS_data=128
STATUS_READ=  0
STATUS_addr=255
STATUS_data=  0

   

I changed clock on 1000kbps .

   

I cant understand why it is not working?please tell me which line of project is wrong?

   

line 200 in my project is true?(is read data operation true?)

0 Likes
lock attach
Attachments are accessible only for community members.
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

this project attached with new changed that i said above

0 Likes
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

No body is here to help me for solving problem?

0 Likes