EEPROM Write issue

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

cross mob
lock attach
Attachments are accessible only for community members.
Mjos
Level 1
Level 1
First like given 5 replies posted 5 sign-ins

Hi there,

I'm writing software for the PSoC (CY8C4125LQI-S433) in which I implemented the emulated EEPROM. I do get the issue that after a random amount of writes to the EEPROM, the PSoC hangs, seems to be in the CySysFlashWriteRow function.

To isolate and reproduce the problem I created a new empty project with only the EEPROM and a LED so I can see when the PSoC hangs. The problem occurs here too so there must be something going wrong in the EEPROM library.

Has anyone else experienced this problem?

 

#include <project.h>

const uint8_t EEPROM_em_EepromStorage[Em_EEPROM_PHYSICAL_SIZE]
__ALIGNED(CY_FLASH_SIZEOF_ROW) = {0u};

uint8_t eepromArray[15] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
cy_en_em_eeprom_status_t   eepromReturnValue;

int main (void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */

    /*Initalize EEPROM with the start address of the memory location*/
    eepromReturnValue = Em_EEPROM_Init((uint32)&EEPROM_em_EepromStorage[0]);
    
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */

    for(;;)
    {
        STAT_LED_Write(1);
        CyDelay(500);
        STAT_LED_Write(0);
        CyDelay(500);
        eepromReturnValue = Em_EEPROM_Write(0u, eepromArray, 15u);
        /* Place your application code here. */
    }
}

 

 

 

 

 

 

 

0 Likes
1 Solution

Hello.

Thanks for providing some details.

Does the Vccd need the capacitor bypassed to ground? (0.1uF)
Yes, it absolutely needs a 0.1uF capacitor from Vccd to ground.  This is the internal 1.8V ARM core voltage.  I'm surprised the PSoC is running even for a few seconds.  Thanks for the picture.

Do you mean Vdda? 
Yes, Vdda.  Sorry for my typo.

We do not use pull-up resistor, is this a problem? No circuitry is connected, only to connector for programming.
I've found that PSoC's XRES does not have a very good internal pull-up resistor.  So I've always put an external 4.7k Ohm resistor on this pin.  I know many of Cypress KIT pcb's do not have a pull-up resistor on target PSoC XRES.  But, the KIT programmer (Kitprog) is providing the pull-up by sourcing XRES.  So, it's a bit misleading when you look at the KIT schematic.

Don’t think this is the issue, the chip was new when we soldered it on the PCB. 
Since the chip was new, as long as the code had this slow (1 second) FLASH write cycle, then the chip should be okay.  However, if it was left running for more than 28 hours (100k/60/60=27.7hr) with 1 second write cycle, the FLASH is burned out.  Since it seems to halt in less than 2 minutes, I don't think you're hitting the 28 hour limit.  I wouldn't replace the chip at this moment.

It sounds like you have a good plan to add the 0.1uF to Vccd.
Let us know if that's the solution (and if it is the solution, don't let it run for 28 hours!!!)

View solution in original post

11 Replies
ncbs
Moderator
Moderator
Moderator
500 replies posted 50 likes received 250 sign-ins

Hi @Mjos ,

I tried your code on the CY8CKIT-041-41XX kit, and I see the LED blink. I don't see any issues with the code and am not able to reproduce the issue.

What is the EEPROM Size defined in the component?

Regards,
Nikhil

0 Likes
Mjos
Level 1
Level 1
First like given 5 replies posted 5 sign-ins

Hi, thanks for the reply.

Odd that it does work with your board. I tried it with an EEPROM size of both 64 and 256 byte.

The led does blink, but only for about 10 seconds, then it hangs. 

0 Likes
ncbs
Moderator
Moderator
Moderator
500 replies posted 50 likes received 250 sign-ins

Hi @Mjos ,

I understand that you are testing using a separate project, but do you have WDT implemented in your application? This might be a possibility if you observe your device halting after a fixed amount of time.

Can you share your project as an archive file?

Regards,
Nikhil

0 Likes
lock attach
Attachments are accessible only for community members.
Mjos
Level 1
Level 1
First like given 5 replies posted 5 sign-ins

Hi Nikhil,

The time the application keeps running varies between 2 and like 20 seconds so the amount of time is not fixed, which makes it even more odd. All WDT timers are disabled too. 

I attached the project below.

 

Kind regards

0 Likes
lock attach
Attachments are accessible only for community members.
ncbs
Moderator
Moderator
Moderator
500 replies posted 50 likes received 250 sign-ins

Hi @Mjos,

You have assigned P2[7]to the status LED, which does not correspond to any onboard LED. You may on of the following pins: 

ncbs_0-1674208090790.png

And you'll be able to see the LED blink. I have used P3[4] in my project.

I have also changed main.c to check if the EEPROM write operation was successful or not. The written data is read and compared with the original array. The status LED blinks only if the check is successful. You can find the attached project in this reply [I have tested this on CY8CKIT-041-41XX].

Regards,
Nikhil

0 Likes
Mjos
Level 1
Level 1
First like given 5 replies posted 5 sign-ins

Hi ncbs,

Thanks for your reply. I use a different board with an external led connected to pin P2[7]. I copied your project, changed the board to the CY8C4125LQI-S433 that I'm using and set the LED pin to P2[7]. When I run the code, it hangs again in the same CySysFlashWriteRow function, just as in the first project. Is there some kind of flash or addressing configuration I am missing?

 

2023-01-24 09_09_02-Debugging - PSoC Creator 4.4  [C__Users_Michiel Josephs_Downloads_Sandbox_Projec.png

0 Likes
BiBi_1928986
Level 7
Level 7
First comment on blog 500 replies posted 250 replies posted

Hello.

I'll take a H/W approach to the problem since I can't open the project (I use Creator 4.2).

Are you using IMO or an external clock?

Have you set SYSCLK to a frequency of 24MHz or less?  24MHz is the max for this device.

Can you provide a screenshot of the PSoC with surrounding power supply connections.  Many people get the Vccd connections wrong.

Is Vcca the highest voltage (or at least equal to Vddd)?

When it stops running, does it only stop when in Debug mode in Creator or, does it also stop running when not running in Debug mode?

BTW, what is PSoC voltage, 5V, 3.3V, 1.8V?

Do you have a pull-up resistor on XRES?  And, what other circuitry drives XRES (if anything)?

Since nothing in your code requires interrupts to be enabled, comment out the

CyGlobalIntEnable

and see what effect that has.

edit:  PSoC FLASH has a limit of 100,000 write cycles.  It's possible that you've worn out the FLASH (with your original code prior to diagnosing the issue) and now it's flakey.
Can you run the 1 second LED blink code on a fresh PSoC chip?

0 Likes
lock attach
Attachments are accessible only for community members.

Hi, thanks for your help, I didn’t look into the power supply yet for this issue.

I checked with the hardware engineer, he checked with the documentation of the CY8C4125LQI-S433 and noted this:

"The chip is connected as described in the documentation except for the VCCD which is floating, and the XRES which is floating too. The previous chip (Cy8C4245LQI-483) was connected in exactly the same manner and did not have any issues with power/EEPROM."

Furthermore, here are the answers to the questions asked:

Are you using IMO or an external clock?

Have you set SYSCLK to a frequency of 24MHz or less?  24MHz is the max for this device.

The IMO drives the SysClk without divider at 24 MHz

Can you provide a screenshot of the PSoC with surrounding power supply connections.  Many people get the Vccd connections wrong.

We don't have a PCB schematic, only the layout. Does the Vccd need the capacitor bypassed to ground? (0.1uF)

Is Vcca the highest voltage (or at least equal to Vddd)?

Do you mean Vdda? Vdda and Vddd are both connected to 3.3V

When it stops running, does it only stop when in Debug mode in Creator or, does it also stop running when not running in Debug mode?

It stops in both debug and normal mode without the programmer connected

BTW, what is PSoC voltage, 5V, 3.3V, 1.8V?

PSoC is running on 3.3V

Do you have a pull-up resistor on XRES?  And, what other circuitry drives XRES (if anything)?

We do not use pull-up resistor, is this a problem? No circuitry is connected, only to connector for programming.

Since nothing in your code requires interrupts to be enabled, comment out the

CyGlobalIntEnable

and see what effect that has.

This did not have any effect

edit:  PSoC FLASH has a limit of 100,000 write cycles.  It's possible that you've worn out the FLASH (with your original code prior to diagnosing the issue) and now it's flakey.
Can you run the 1 second LED blink code on a fresh PSoC chip?

Don’t think this is the issue, the chip was new when we soldered it on the PCB. We could try to replace it this week to see if there’s any difference

We'll try to pull the Vccd to ground with the capacitor to see if there's any difference

0 Likes

Hello.

Thanks for providing some details.

Does the Vccd need the capacitor bypassed to ground? (0.1uF)
Yes, it absolutely needs a 0.1uF capacitor from Vccd to ground.  This is the internal 1.8V ARM core voltage.  I'm surprised the PSoC is running even for a few seconds.  Thanks for the picture.

Do you mean Vdda? 
Yes, Vdda.  Sorry for my typo.

We do not use pull-up resistor, is this a problem? No circuitry is connected, only to connector for programming.
I've found that PSoC's XRES does not have a very good internal pull-up resistor.  So I've always put an external 4.7k Ohm resistor on this pin.  I know many of Cypress KIT pcb's do not have a pull-up resistor on target PSoC XRES.  But, the KIT programmer (Kitprog) is providing the pull-up by sourcing XRES.  So, it's a bit misleading when you look at the KIT schematic.

Don’t think this is the issue, the chip was new when we soldered it on the PCB. 
Since the chip was new, as long as the code had this slow (1 second) FLASH write cycle, then the chip should be okay.  However, if it was left running for more than 28 hours (100k/60/60=27.7hr) with 1 second write cycle, the FLASH is burned out.  Since it seems to halt in less than 2 minutes, I don't think you're hitting the 28 hour limit.  I wouldn't replace the chip at this moment.

It sounds like you have a good plan to add the 0.1uF to Vccd.
Let us know if that's the solution (and if it is the solution, don't let it run for 28 hours!!!)

Hi, thanks for the help! The absence of the capacitor seems to be the problem.

We soldered the capacitor on the board which failed before, which now seems to be working successfully with the testprogram.

I think it can be concluded that with the absence of the capacitor the chip will be very sensitive to voltage dips, like when writing the EEPROM. 

edit: 

removed one testcase because I accidentally left the watchdog on 

0 Likes

That's great news!

Thanks for the update.