View previous topic :: View next topic |
Author |
Message |
Jeetdesai
Joined: 05 Jul 2018 Posts: 18
|
Is it possible to see EEPROM usage? |
Posted: Fri Aug 24, 2018 9:15 am |
|
|
I have a PIC16F917 with 256 bytes of EEPROM. The whole code is working fine, but I'd like to see how much of EEPROM is used. When I press the Statistics button, it leads me to a tab that gives details on RAM and ROM, but there is no EEPROM specifically. Is there anyway that I can see the usage of EEPROM? |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Fri Aug 24, 2018 10:07 am |
|
|
MPLAB will show you exactly what is in the EEPROM either in simulation or on a real chip.
The compiler can't tell you how much EEPROM is going to be used as you can calculate EEPROM addresses as the program runs.
Mike |
|
|
Jeetdesai
Joined: 05 Jul 2018 Posts: 18
|
Solved |
Posted: Fri Aug 24, 2018 12:53 pm |
|
|
Thank You Mike for the comments.
I first compiled my project in CCSC to make sure it didn't have any errors. I then made a new project in MPLABX. I made sure to pick the same PIC microcontroller and then chose CCSC as the compiler.
I then included the main '.c' [make sure the 'c' is lower case or else it might consider it as C++ and give additional errors] file in the "Source File" folder. Then I included '.h' files in "Header Files' folder and finally the other '.c' files in the 'Important Files' folder. Then compiled the code and it was successful.
Then I went to the 'Window' option in the menubar and clicked on 'PIC Memory views' >> 'Program Memory'. A new dialog box opened in the Left side bottom.
I selected the 'EE Data Memory' in the Memory option.
I then counted all the bytes per address. I think to count the data per address, it might be in bytes or bits. Because some external Flash memories come in bits/kbits while others come in terms of bytes/kbytes/Mbytes. The data sheet mentioned that the EEPROM in my microcontroller had 8-bit data per address or 1 Byte per address.
---------------------------------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx---------------
Eg: My EEPROM has 256Bytes of EEPROM, so 00 to FF in hex. The table went
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
10 FF .. .. FF
. .
. .
. .
F0 FF .. .. FF
---------------------------------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-----------
So, 8-bytes out of 256 were free, meaning 248 Bytes were used.
Sorry for the long explanation. I hope it helps someone else. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Solved |
Posted: Fri Aug 24, 2018 1:20 pm |
|
|
Jeetdesai wrote: |
My EEPROM has 256Bytes of EEPROM, so 00 to FF in hex. The table went
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
10 FF .. .. FF
. .
. .
. .
F0 FF .. .. FF
So, 8-bytes out of 256 were free, meaning 248 Bytes were used.
Sorry for the long explanation. I hope it helps someone else.
|
Your explanation is not correct.
The first 16 bytes in the table above are set to 0x00.
These bytes are in use.
0xFF is the erased state, so 240 bytes are free. (256 -16 = 240). |
|
|
Jeetdesai
Joined: 05 Jul 2018 Posts: 18
|
|
Posted: Fri Aug 24, 2018 9:35 pm |
|
|
Thank You PCM for correcting me.
What if one of the addresses has 0F or C6? Is the whole address considered to be used? Or can I consider some of the bits in that address to be free? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Fri Aug 24, 2018 11:22 pm |
|
|
Unlike flash memory, EEPROM is written/erased on a per byte basis. You can set bits on/off at will. So you can change a byte to any value you want. Key problem is how you 'know' a byte is used or unused?. The erased state from the programmer is 0xFF, so if you treat this as the 'unwritten' state, then you have to consider every byte containing anything else as 'written'. So potentially there is no reason you can't change bits in a byte set to 0xC6, to 0xC5 for example, but both bytes are equally 'used'. The byte is the entity. |
|
|
Jeetdesai
Joined: 05 Jul 2018 Posts: 18
|
|
Posted: Mon Aug 27, 2018 7:32 am |
|
|
Thank You Ttelmah. |
|
|
|