I am using Cy8C27443. I'm trying to write an array of int type (ADC values) to E2PROM then read back using button polling. However, I am facing problem writing values to E2PROM. I test the writing by iniitializing a RAM buffer as in this app note (http://www.cypress.com/?id=4&rID=60878). However it didn't work, I have read the E2PROM datasheet and technical reference manual, checked the size of my buffer, modified flash security.txt but it's not working.

I attached my prj below. Could you please give it a look and tell me what I did wrong, thank you very much!

@EricS: I thought that int type takes 4 bytes of data but when I checked the Compiler Guide and found out that the int type in psoc only takes 2 bytes, so I was wrong about it. Besides I made a mistake at "if (bError == E2PROM_1_NOERROR)".

About a different buffer, do you mean the address of the E2PROM I have written to or something? I learned from the app note which Danaa provided, they did the same, I found nothing wrong here.

I usually put into my EEProm-structure a datafield to count the number of writes, when the value is zero (0) I assume that it has not been written yet and I initialize it by writing to it the first time. Later in the life of the device I have the opportunity to change the target address within the EEProm array when there have been too many writes (could be limited to 10K or 100K).

After writing an array to E2PROM, I want to read each value in the array by its index.

The process I've done in the prj is read it back to a readbuffer, each time I push a button the index will be up (down) by one value, reflected by the readbuffer.address and then the LCD will display the value at the indexed value.

However, when I push button, the address value just goes up (or down) and doesn't stop, even after I release the button. I thought that would be debounce problem but it isn't.

As Bob says, I put everything in the while loop and it runs like forever so I take the "action" out and check it out of the loop, then I used the delay() functions instead of sleep timer decrement, now everything works fine :)