Microchip's __EPROM_DATA macro statement
Moderator: Benj
Microchip's __EPROM_DATA macro statement
Microchip's help desk said the __EEPROM_DATA macro is the only way they recommend to initialize the EEPROM values at programming time.
E.G. place as many '8 byte' long __EEPROM_DATA statements as you need. It is simple and works always. Compiler places data in the order you will have them in your C code. If you need some bytes to be unchanged then place 0xFF for them. Eg.
__EEPROM_DATA(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); // addr: 0x00 ... 0x07
__EEPROM_DATA(0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88); // addr: 0x08 ... 0x0F
__EEPROM_DATA(0x55, 0x66, 0x87, 0x65, 0xFF, 0xFF, 0xFF, 0xFF); // addr: 0x10 ... 0x17
etc
etc
But it is unwieldy and for a 256 bytes of on board PIC EEPROM you end up with 32 statements.
My question: Where do I place these statements in Flowcode? In a Calculation icon or in the Supplementary Code or some other?
Thanks in advance.
E.G. place as many '8 byte' long __EEPROM_DATA statements as you need. It is simple and works always. Compiler places data in the order you will have them in your C code. If you need some bytes to be unchanged then place 0xFF for them. Eg.
__EEPROM_DATA(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); // addr: 0x00 ... 0x07
__EEPROM_DATA(0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88); // addr: 0x08 ... 0x0F
__EEPROM_DATA(0x55, 0x66, 0x87, 0x65, 0xFF, 0xFF, 0xFF, 0xFF); // addr: 0x10 ... 0x17
etc
etc
But it is unwieldy and for a 256 bytes of on board PIC EEPROM you end up with 32 statements.
My question: Where do I place these statements in Flowcode? In a Calculation icon or in the Supplementary Code or some other?
Thanks in advance.
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
Re: Microchip's __EPROM_DATA macro statement
Use the EEPROM component. It allows you to specify the initial data and generates the required code.
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
Re: Microchip's __EPROM_DATA macro statement
Hi Kersing
I thought the EEPROM component was a run-time component not a pre-run-time component. Does it set the EEPROM cells when the PIC is being programmed before PIC code is running?
I thought the EEPROM component was a run-time component not a pre-run-time component. Does it set the EEPROM cells when the PIC is being programmed before PIC code is running?
- 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:
Re: Microchip's __EPROM_DATA macro statement
The EEPROM component generates the "__EEPROM_DATA" statements for you based on the Initial Values component property.
For example I used these initial values.
And the generated code looks like this.
For example I used these initial values.
Code: Select all
1,2,3,4,5,6,7,8,9,10
Code: Select all
#ifdef MX_CAL_PIC
__EEPROM_DATA(1,2,3,4,5,6,7,8);
__EEPROM_DATA(9,10,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF);
#endif
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
Re: Microchip's __EPROM_DATA macro statement
Hi Ben
Ok so just making sure I understand this. What you are saying is the Flowcode EPROM component generates the EEROM code inserted when the chip is programmed. So if the program, when running, later changes some of the EEPROM values, AND I later reboot/repower the chip, the EEPROM values in the chip will be the later values NOT the values from the __EEPROM_DATA statements. The __EEPROM_DATA statements just provide the initial programmed values? Has no impact on anything after the initial programming?
Thanks Ben.
Ok so just making sure I understand this. What you are saying is the Flowcode EPROM component generates the EEROM code inserted when the chip is programmed. So if the program, when running, later changes some of the EEPROM values, AND I later reboot/repower the chip, the EEPROM values in the chip will be the later values NOT the values from the __EEPROM_DATA statements. The __EEPROM_DATA statements just provide the initial programmed values? Has no impact on anything after the initial programming?
Thanks Ben.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Microchip's __EPROM_DATA macro statement
Hi crispin12,
Yes, what you stated is indeed correct.
The EEPROM Values embedded during programming will remain until they are changed.
Once changed, the EEPROM value will remain the changed EEPROM value, even after power is removed then restored.
Yes, what you stated is indeed correct.
The EEPROM Values embedded during programming will remain until they are changed.
Once changed, the EEPROM value will remain the changed EEPROM value, even after power is removed then restored.
Martin
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
Re: Microchip's __EPROM_DATA macro statement
Reset/repower will not rewrite the values, so you will read what has been written last (by you).crispin12 wrote:So if the program, when running, later changes some of the EEPROM values, AND I later reboot/repower the chip, the EEPROM values in the chip will be the later values NOT the values from the __EEPROM_DATA statements.
Yes, but keep in mind next time you program the chip with code the eeprom data will be reset to the values in your flowchart, overwriting any values you stored in between. So 'initial' is relative, every programming cycle will overwrite the values.crispin12 wrote:The __EEPROM_DATA statements just provide the initial programmed values? Has no impact on anything after the initial programming?
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
Re: Microchip's __EPROM_DATA macro statement
Ben,
Just tried the EEPROM component using data copied from your earlier reply example into the PIC1936 and after compiling and looking at the generated c code there is no
#ifdef MX_CAL_PIC
__EEPROM_DATA(1,2,3,4,5,6,7,8);
__EEPROM_DATA(9,10,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF);
#endif
anywhere in the file.
The compiler report also indicates EEPROM space used 0%. The Flowcode EEPROM is not setting up any initialisation values at all.
I am attaching the flowcode file and the generated c file for your attention. It is definitely not working in PIC1936 which is the chip I am working with at the moment. I understand from the Microchip forum that there are problems when the EEPROM is not real EPROM but is HEF RAM however the data sheet definitely indicates that this PIC has 256 EEPROM on board so I am at a loss. I inserted the data as a string of decimal numbers separated by commas just like your example. Have also tried adding a complete table of 256 comma delimited entries into the EEPROM box for initialisation values. It makes no difference. I simply cannot get the generated code to show any EEPROM initialisation.
=================================================================================
Ok. It must be something I'm not doing or I'm missing cos' just tried again on a bog standard 16F84A and I can not get any code showing in that either. This is sooooooooooo annoying!!! You just need to insert the initialisation values into the EEPROM properties right?
Just tried the EEPROM component using data copied from your earlier reply example into the PIC1936 and after compiling and looking at the generated c code there is no
#ifdef MX_CAL_PIC
__EEPROM_DATA(1,2,3,4,5,6,7,8);
__EEPROM_DATA(9,10,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF);
#endif
anywhere in the file.
The compiler report also indicates EEPROM space used 0%. The Flowcode EEPROM is not setting up any initialisation values at all.
I am attaching the flowcode file and the generated c file for your attention. It is definitely not working in PIC1936 which is the chip I am working with at the moment. I understand from the Microchip forum that there are problems when the EEPROM is not real EPROM but is HEF RAM however the data sheet definitely indicates that this PIC has 256 EEPROM on board so I am at a loss. I inserted the data as a string of decimal numbers separated by commas just like your example. Have also tried adding a complete table of 256 comma delimited entries into the EEPROM box for initialisation values. It makes no difference. I simply cannot get the generated code to show any EEPROM initialisation.
=================================================================================
Ok. It must be something I'm not doing or I'm missing cos' just tried again on a bog standard 16F84A and I can not get any code showing in that either. This is sooooooooooo annoying!!! You just need to insert the initialisation values into the EEPROM properties right?
- Attachments
-
- test_pic1936.fcfx
- (4.6 KiB) Downloaded 354 times
-
- test_pic1936.c
- (3.07 KiB) Downloaded 394 times
- 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:
Re: Microchip's __EPROM_DATA macro statement
Hello,
You're not using any of the component macros in your program so the code is not being generated for the component. If you add a component macro to read or write an EEPROM location then the code generation should kick in.
You're not using any of the component macros in your program so the code is not being generated for the component. If you add a component macro to read or write an EEPROM location then the code generation should kick in.
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
Re: Microchip's __EPROM_DATA macro statement
Eh? ... so you have to have a run time instruction in order to get the programmer insert EEPROM initialisation values during programing? Ben I'm confused. Why? The programing of values into a chip should have no dependencies on the compiled run-time code fetched by the program counter at boot up. You don't have to use a run time component to set up the programming configuration words like WDT, MCLR, BOR and so on. These are default initialisation instructions. EEPROM code inserted at programming time should have no bearing on what the program code contains, surely?
So basically what you are saying is that I have to make my program read the EEPROM code at some point after boot up just to burn some EEPROM cells during programming?..and by so doing effectively utilising ROM program space to achieve this.
Is there absolutely no other way to insert pre-defined data into an EEPROM using Flowcode? I simply need to insert just 1 byte at a single address. Job done!
So basically what you are saying is that I have to make my program read the EEPROM code at some point after boot up just to burn some EEPROM cells during programming?..and by so doing effectively utilising ROM program space to achieve this.
Is there absolutely no other way to insert pre-defined data into an EEPROM using Flowcode? I simply need to insert just 1 byte at a single address. Job done!
- 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:
Re: Microchip's __EPROM_DATA macro statement
Hello,
If you never read the EEPROM value then why do you need it to be programmed
It's basically just the way Flowcode components work, if you don't call any of their functions then they don't generate any code.
You can always call the function inside the yes branch of an decision icon with the parameter set to 0 if you need the EEPROM value to be programmed but never want to actually read the value.
If you never read the EEPROM value then why do you need it to be programmed
It's basically just the way Flowcode components work, if you don't call any of their functions then they don't generate any code.
You can always call the function inside the yes branch of an decision icon with the parameter set to 0 if you need the EEPROM value to be programmed but never want to actually read the value.
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
- CamargoF
- Posts: 36
- Joined: Thu Aug 02, 2018 8:16 pm
- Location: Sao Paulo, SP - Brazil
- Has thanked: 6 times
- Been thanked: 7 times
- Contact:
Re: Microchip's __EPROM_DATA macro statement
Additional comments:
- The usage of Initial Value property of EEPROM component does not work properly when you need to initialize an 256-byte EEPROM. On console the EEPROM data has been overwritten many times, destroying the desired initialization.
- Initialize the EEPROM by code make the coding unnecessarily complex and consume part of the FLASH memory with something that could be on HEX-file.
- Initializing on the fly is good when you need to preserve any old data, but it may create problem on PIC firmware programming. There is a time gap (few seconds) between the firmware programming and the firmware verification where the update code will run. I the running code update any EEPROM data, the verification will fail. To avoid it you need to add few seconds delay to your code, longer than the gap between the programming and verification.
- 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:
Re: Microchip's __EPROM_DATA macro statement
Hello,
The generated code looks ok, just investigating the console data.
Console init did have a bug if you had more than 256 characters in the initialise string which has now been fixed. The fixed v7 component file is attached and the fixed v8 component file is available via the update system
Simply copy to your Flowcode 7/components directory and restart Flowcode.
Please can you provide an example project that shows this.The usage of Initial Value property of EEPROM component does not work properly when you need to initialize an 256-byte EEPROM.
The generated code looks ok, just investigating the console data.
Code: Select all
#ifdef MX_CAL_PIC
__EEPROM_DATA(0,1,2,3,4,5,6,7);
__EEPROM_DATA(8,9,10,11,12,13,14,15);
__EEPROM_DATA(16,17,18,19,20,21,22,23);
__EEPROM_DATA(24,25,26,27,28,29,30,31);
__EEPROM_DATA(32,33,34,35,36,37,38,39);
__EEPROM_DATA(40,41,42,43,44,45,46,47);
__EEPROM_DATA(48,49,50,51,52,53,54,55);
__EEPROM_DATA(56,57,58,59,60,61,62,63);
__EEPROM_DATA(64,65,66,67,68,69,70,71);
__EEPROM_DATA(72,73,74,75,76,77,78,79);
__EEPROM_DATA(80,81,82,83,84,85,86,87);
__EEPROM_DATA(88,89,90,91,92,93,94,95);
__EEPROM_DATA(96,97,98,99,100,101,102,103);
__EEPROM_DATA(104,105,106,107,108,109,110,111);
__EEPROM_DATA(112,113,114,115,116,117,118,119);
__EEPROM_DATA(120,121,122,123,124,125,126,127);
__EEPROM_DATA(128,129,130,131,132,133,134,135);
__EEPROM_DATA(136,137,138,139,140,141,142,143);
__EEPROM_DATA(144,145,146,147,148,149,150,151);
__EEPROM_DATA(152,153,154,155,156,157,158,159);
__EEPROM_DATA(160,161,162,163,164,165,166,167);
__EEPROM_DATA(168,169,170,171,172,173,174,175);
__EEPROM_DATA(176,177,178,179,180,181,182,183);
__EEPROM_DATA(184,185,186,187,188,189,190,191);
__EEPROM_DATA(192,193,194,195,196,197,198,199);
__EEPROM_DATA(200,201,202,203,204,205,206,207);
__EEPROM_DATA(208,209,210,211,212,213,214,215);
__EEPROM_DATA(216,217,218,219,220,221,222,223);
__EEPROM_DATA(224,225,226,227,228,229,230,231);
__EEPROM_DATA(232,233,234,235,236,237,238,239);
__EEPROM_DATA(240,241,242,243,244,245,246,247);
__EEPROM_DATA(248,249,250,251,252,253,254,255);
#endif
Simply copy to your Flowcode 7/components directory and restart Flowcode.
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