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!
Solved! Go to Solution.
Thanks Eric and Danaa,
@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.
Now my code works well, thank you very much!
Hi, I have another question about E2PROM.
In the example CE57347, the E2PROM is initialized with the StoredValues at address 0x7FC0 and there is only "U" in the flashsecurity.txt so I assume the StoredValues is saved at that address.
Then the WriteData struct is written to the E2PROM so is the StoredValues overwritten or not?
'U' stands for unprotected, so when the EEProm address is 0x7FC0 it will be overwritten. Note that this may fail depending on the PSoC you use, there might be different EEProm start addresses.
Some additional hints:
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).
Hi, it's me again. I have a problem with reading an array in E2PROM.
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.
(I followed the debounce example here: http://www.ece.drexel.edu/courses/ECE-C304/notes/PSoCDesigner_PSoC1_SleepTimer.txt One thing that in my project, I have already used a timer interrupt so I don't want another interrupt.)
Please take a look at my attached project and give me some advice, thank you very much
Normally you want to bounce a button on and then follow it by bouncing it off,
then execute the button function. Ie. a press and release approach before
executing the function.
Buttons come in many kinds of quality, some bounce several hundred mS.
Attached some approaches to debouncing.
Consider replacing this code -
writebuffer.buffer = 1;
writebuffer.buffer = 2;
writebuffer.buffer = 3;
writebuffer.buffer = 4;
writebuffer.buffer = 5;
writebuffer.buffer = 6;
writebuffer.buffer = 7;
writebuffer.buffer = 8;
writebuffer.buffer = 9;
writebuffer.buffer = 10;
writebuffer.buffer = 11;
writebuffer.buffer = 12;
writebuffer.buffer = 13;
writebuffer.buffer = 14;
writebuffer.buffer = 15;
writebuffer.buffer = 16;
writebuffer.buffer = 17;
writebuffer.buffer = 18;
writebuffer.buffer = 19;
writebuffer.buffer = 20;
writebuffer.buffer = 21;
writebuffer.buffer = 22;
writebuffer.buffer = 23;
writebuffer.buffer = 24;
for (i = 0; i < 25; writebuffer.buffer[ i ] = i + 1, i++);
For delay functions consider -
You set the variable "action" when a button is pressed, but you do not reset the action to not doing anything when the button is released.
I would suggest you to wait at the end of the loop for the button to be released.
Thanks for your answers 🙂
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 🙂
Again, thank you very much!!!