Hello...
I'm new on Flowcode, and i have a question about eeprom
i know how to read and write on eeprom .. but imagine that the power go out on my pic... when i power on again, the pic will start the program from the beginnig. how can i program the values directly into eeprom ?
for example ...
i start my flowchart on flowcode... in begining of the program, i program eeprom localization "1" with value 234 for example ... in the middle of the program, i change that value to 124 for example... if power go out, and i start over again the program will start from the beginnig and will put in localization "1" the value 234.. but i want program for not change that value and start where it when the program stoped...
after some program testes with flowcode... i saw that, when the program generate de .hex file and i open with software to program the pic, in the zone that appear the content of epprom is always empty ..
how can i solve this ..
can someone help me ?
PS: sorry about my bad english, I'm from Portugal, and i don't write english very well
EEprom doubts
-
- Posts: 30
- Joined: Tue Dec 26, 2006 9:04 pm
- Has thanked: 2 times
- Been thanked: 1 time
Hello Carlos, to program directly a value in eeprom, value which stays every time you shut down power, you must put it in the software to program the pic, at the moment you program the pic, in the zone where appears the content of epprom. For exemple, load your hex file in the pic programmer, in the zone where appears the content of epprom, in first adress (0000), in first bite, write FF if you want 255 to be written in adress 1.
So in flowcode, at the bigining of your program , just read eeprom at adress 1, you will get the value 255.
Later in you program, using eeprom component in flowcode, write the new value(for exemple 124) in the eeprom at adress 1.
Now, when you shut down power, and start again, the program will first read the last value recorded in adress 1 of the eeprom, so 124 in this case.
I hope to have answer to your questions, if not enough, just ask.
Best regards.
So in flowcode, at the bigining of your program , just read eeprom at adress 1, you will get the value 255.
Later in you program, using eeprom component in flowcode, write the new value(for exemple 124) in the eeprom at adress 1.
Now, when you shut down power, and start again, the program will first read the last value recorded in adress 1 of the eeprom, so 124 in this case.
I hope to have answer to your questions, if not enough, just ask.
Best regards.
-
- Posts: 30
- Joined: Tue Dec 26, 2006 9:04 pm
- Has thanked: 2 times
- Been thanked: 1 time
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Using flowcode V3 is should be possible to place the EEPROM value straight into the memory. You have to keep in mind that you use the advanced configuration of PPP to unlock the writing of the EEPROM when you download your initial code. Any further code must the be programmed after first making sure that the EEPROM write is disabled. Otherwise your EEPROM memory will all be reset to 0 or the value set in your new program.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Steve
- Matrix Staff
- Posts: 3433
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
To put data into the EEPROM that does not get reset when the PICmicro is reset or loses power, put the following into the "definitions" section of the "supplementary code" section (assuming you're using v3):
This will put the values 12, 34, 56(hex) and 78(hex) into locations 0-3 of EEPROM, and the ASCII codes for A-D into locations 4-7.
Code: Select all
//Put some data into eeprom
#pragma DATA 0x2100, 12, 34, 0x56, 0x78, "ABCD"
-
- Posts: 30
- Joined: Tue Dec 26, 2006 9:04 pm
- Has thanked: 2 times
- Been thanked: 1 time
-
- Posts: 209
- Joined: Thu Oct 19, 2006 11:46 am
- Location: Bakewell, UK
- Has thanked: 20 times
- Been thanked: 16 times
Steve,
Thanks for the above, where does the address value 0x2100 come from? The data sheet for my preferred device 16F876 quotes:
"When interfacing the program memory block, the
EEDATA and EEDATH registers form a two-byte word
that holds the 14-bit data for read/write and the EEADR
and EEADRH registers form a two-byte word that holds
the 13-bit address of the program memory location
being accessed. These devices have 4 or 8K words of
program Flash, with an address range from 0000h to
0FFFh for the PIC16F873A/874A and 0000h to 1FFFh
for the PIC16F876A/877A. Addresses above the range
of the respective device will wraparound to the
beginning of program memory."
Is 0x2100 the same for all the PIC devices that have EEPROM?
Thanks for the above, where does the address value 0x2100 come from? The data sheet for my preferred device 16F876 quotes:
"When interfacing the program memory block, the
EEDATA and EEDATH registers form a two-byte word
that holds the 14-bit data for read/write and the EEADR
and EEADRH registers form a two-byte word that holds
the 13-bit address of the program memory location
being accessed. These devices have 4 or 8K words of
program Flash, with an address range from 0000h to
0FFFh for the PIC16F873A/874A and 0000h to 1FFFh
for the PIC16F876A/877A. Addresses above the range
of the respective device will wraparound to the
beginning of program memory."
Is 0x2100 the same for all the PIC devices that have EEPROM?
Go with the Flow.
- Steve
- Matrix Staff
- Posts: 3433
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
The quote you have is for accessing Program memory (i.e. the Flash where your program is stored). I don't think this 0x2100 figure is quoted in the actual device datasheet.
Instead, you need to look in the programming specification document for a particular PIC. These are 2 quotes from the 16F87Xa document:
Instead, you need to look in the programming specification document for a particular PIC. These are 2 quotes from the 16F87Xa document:
The user memory space extends from 0000h to 1FFFh
(8 K words). In Programming mode, the program memory
space extends from 0000h to 3FFFh, with the first
half (0000h - 1FFFh) being user program memory and
the second half (2000h - 3FFFh) being configuration
memory.
The value 0x2100 should be correct for most 16F devices.The 256 data memory locations are logically mapped
starting at address 2100h. The format for data memory
storage is one data byte per address location, LSB
aligned.