View previous topic :: View next topic |
Author |
Message |
murtis
Joined: 12 Aug 2007 Posts: 41
|
How to write the PIC16F877 code to EEPROM? |
Posted: Fri Nov 09, 2007 2:40 pm |
|
|
Hi,
I wrote the code for PIC16F877. But, there is no place in PIC16F877 anymore... So, I want to write the code, that is wrote for PIC16F877, to 24C128. How can i do this event_?
Could you help me about this, please_?
Thanks... _________________ MurtiS |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri Nov 09, 2007 4:30 pm |
|
|
Sorry, but with a PIC16 you can not run program code from an external memory. As far as I see you have the following options:
1) Optimize your code so it uses less space.
2) Choose another processor with more memory (if I remember correctly there is a pin compatible PIC18)
3) Rewrite your program as a kind of interpreter, then you can run code from the external memory. This is similar to how the BASIC Stamp interpreter product works. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sat Nov 10, 2007 9:00 am |
|
|
I just thought of another option.
You can not store executable code in the external eeprom but often when a program gets very large this is because you have a lot of constant data (strings, LCD-graphics, etc.). This constant data can be stored on an external memory if you want to. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sat Nov 10, 2007 9:22 am |
|
|
Quote: | Now, i am using PIC18F4620... But, there is no place in PIC18F4620 Memory... So, if i can use external memory for my program, i will decide to use PIC16F877 with 24c256...
PIC18F4620 memory is 32Kb
24C256 memory is 128Kb... | Don't confuse bits, bytes and words.
The PIC18F4620 has 64kbyte == 32kbyte program words (1 instruction takes 16 bits on PIC18)
The PIC16F877 has 14kbyte = 8k program instructions (1 instruction = 14 bits on PIC16)
A 24c256 eeprom has 256kbits = 32kbyte
Conclusion:
A PIC16F877 with 24c256 = 8k instructions + 32k data
A PIC18F4620 with same 8k instructions takes 16kbytes. Leaves 64k - 16k = 48kbytes for data.
If it doesn't fit in the PIC4620 now, then it is not going to fit in the PIC16F877 + 24c256 either !
Quote: | i should write the code, that is wrote for PIC18F4620, to EEPROM... But, i do not know How i can. | Have a look at the driver directory supplied with the CCS compiler, many EEPROM driver examples can be found there. |
|
|
|