Announcements
Community Announcement : Welcome to the NEW Cypress Developer Community.
cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4

Anonymous
Not applicable

hi,

   

I am trying to write/read data to/from external eeprom(24C02B) using Psoc4. i tried a simple code of writing 1 byte in external eeprom and then reading the same byte but the returned byte is not the one i m writing, find the attached project.

   

the result i m getting is something like this {00}{00}{00}{04}{00}{00}{06}.

   

Kindly guide with the solution

   

 

   

Regards

   

rnc

0 Likes
14 Replies
Bob_Marlowe
Expert II

Welcome in the forum!

   

You missed to issue an I2C_SendStop() after writing the byte to the eeprom.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

hi bob,

   

Thanks for the reply, but with this change i not getting any response not even the previous one

   

please guide me

   

regards

0 Likes
Bob_Marlowe
Expert II

Which Cypress kit do you use?

   

"not getting any response" is usually the case when there is a hardware I2C problem.

   

Not even a response from the first SendStart()???

   

What did you connect to the Tx-pin of the UART?

   

 

   

Bob

0 Likes
Anonymous
Not applicable

bob i m not using any kit i burned the code in psoc ic CY8C4245AXI-483 which is connected in one of my on going project, and talking about hardware the scl n sda pins of psoc4 is connected to eeprom 24c02b scl n sda through pull up of 1 k. At tx pin i am using FTDI to display data. As i mentioned earlier without I2C_SendStop() after writing the byte to the eeprom it is giving me this response {00}{00}{00}{04}{00}{00}{06} but when i insert Sendstop after eeprom write m getting no response.

   

1. The code which i post in previous post is correct i mean the steps to write and read from eeprom??

   

2. Do i need to right shift slave id by 1 bit 0x28 instead of 0x50 ?? if yes then i tried doing that also but no luck

   

 

   

regards

   

rnc

0 Likes
Bob_Marlowe
Expert II

Your code looks ok, the address is set correctly with 0x50, pullups a bit low, but should work.

   

You set the PSoC internally for 3.3V, but the eeprom needs 5V. Doesn't matter yet when you run the chip at 5V

   

The (rather small) eeprom is obsolete, so probably a replacement should be used. I can give you a tip: Cypress now fabricates FRam chips which are quite faster and have better performance than eeproms.

   

Care must be taken (after you got the eeprom running) for power losses during the programming cycle or data-lossed due to power fail or brown-outs may happen.

   

The eeprom datasheet states that after the SendStop() is issued the write-cycle will start which does not allow any further access to the device, so a delay of 20ms is advisable before a re-read happens.

   

The PSoC4 has got emulated eeprom which is only guaranteed for 100k write-cycles and uses the internal flash memory. Could be a much cheaper solution than an external chip.

   

How are you programming the chip? Do you use a MiniProg3??

   

So, what I would like to see are the returned status bytes for each I2C-access from the beginning to the end of the cycle.

   

The first non-zero returned value indicates an error and no further access to the eeprom should be made.

   

 

   

Bob

0 Likes
Bob_Marlowe
Expert II

... oh, yes, I forgot: Use Cypress Update Manager to update your Creator, components and Programmer versions to the latest .

   

 

   

Bob

0 Likes
ETRO_SSN583
Esteemed Contributor

If you need the higher erase/write lifetime of EEPROM then consider

   

implementing wear leveling in the flash. Basically keep track of how

   

many erase/write cycles you have done in a specific address range

   

and when you exceed that start using the next block of FLASH. Even

   

better implement error correction/detection and use error correction

   

as the trigger for moving to the next block. FLASH under most conditions

   

outperforms its worst case erase/write lifetime spec. So latter method

   

would yield much greater use before moving to next FLASH region.

   

 

   

    

   

          http://en.wikipedia.org/wiki/Wear_leveling

   

 

   

Note if you do this the power supply must be capable of holding up power

   

long enough to implement moving to the next FLASH region. Thats normally

   

accomplished with a large cap on Vdd and diode isolation between Vdd reg-

   

ulator and PSOC Vdd for power failure. Note some regulators when they lose

   

power at input do not place any load on their outputs, eg. you would be able to

   

eliminate the diode, you have to examine datasheet to confirm this.

   

 

   

Regards, Dana.

0 Likes
HeLi_263931
Honored Contributor II

When you connect a 3.3V PSoC with a 5V EEPROM via I2C, you have a problem. Either the PSoC GPIOs are pulled up to 5V (which could be bad if you don't use SIO pins), or they are pulled to 3.3V and then the voltage might not be sufficient.

   

Apart from that: a write cycle takes 10ms, regardless of page or byte write. If a write is still in progress, the read won#t be acknowledged. Thats what you are seeing - adding the I2C stop that Bob advised you makes the write actually happen, but the read fails since the EEPROM is still busy. Look at chapter 5.0 in the data sheet (Acknowledge Polling).

0 Likes
Anonymous
Not applicable

hey guys

   

Thanks for all your support, my issue is resolved now i can read n write to external eeprom.

   

Here is the working code

   

Thanks n regards

   

ratna

0 Likes
Anonymous
Not applicable

Hello Madam

   

Thank you so much... It works fine..

0 Likes
moro_1580446
New Contributor II

Hi everybody.I want to running at24c512 with psoc5lp.I changed chip select of your project( I2C_EEPROM.cywrk.Archive03.zip) file to psoc5lp but it is not working.I just get 255 as data.why it is not working?is there anybody here that know what is problem?

   

my project attached...

   

tanks for attention...

0 Likes
Bob_Marlowe
Expert II

It would not be too bad to check the results of your I2C APIs for non-zero which indicates an error.

   

Usually the read of the last (or only) byte should be NAKed by master, not ACKed.

   

 

   

Bob

   

 

   

Bob

0 Likes
moro_1580446
New Contributor II

I read status of every I2C APIs , every status being zero(so means that is it correct?) and i change ACK to NAK but i get 255 from chip memory again.why it is not working?what can i do to solved problem?

   

Another question, is my chip address correct? or not?

   

I changed clock bitrate to 100 kbps and pin drive mode is opendrain draw low.I pullup SDA and SCL pin by 2.2k ohm.

0 Likes
moro_1580446
New Contributor II

I changed my code and it is worked correctly for the first time (after power up),for second  and third...write operation it is not worked.I dont know why it is happening?can you help me?

   

Please help...

   

Thanks

0 Likes