|
|
View previous topic :: View next topic |
Author |
Message |
thangapandi
Joined: 27 Aug 2012 Posts: 6 Location: Madurai
|
how to use program memory as data memory in pic16f877a |
Posted: Thu Sep 06, 2012 2:36 am |
|
|
am getting not enough RAM memory in pic16f877a using CCS.
can any one give help on this
how to i store and get back the same strings in program memory
char a[]="-------",b[]="-------",c[]="-------",d[]="-------"; |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Thu Sep 06, 2012 6:29 am |
|
|
check out:
Code: | const int foo[10]={1,2,3,4,5,6,7,8,9,0}; |
_________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
NEW_GUY
Joined: 31 Aug 2012 Posts: 10 Location: India
|
|
Posted: Thu Sep 13, 2012 4:20 am |
|
|
You can use the following api provoded by the ccs compiler, you can refer them into the help..
write_bank (bank, offset, value)
value = read_bank (bank, offset)
Regards, |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19557
|
|
Posted: Thu Sep 13, 2012 7:41 am |
|
|
Er. No.
The write_bank and read_bank functions access the RAM, not the program memory.
The functions to read and write the program memory are:
write_program_memory
read_program_memory
Fairly 'obvious' names....
Now, storing anything at all 'variable' in the flash program memory has a number of issues:
First the memory has a limited write life. Every time an erase cycle is performed on a memory cell, it uses up one life. The program memory on the 877a, only offers 1000 lives. So changing anything even once a day, will destroy the chip quite quickly.
Then when you are writing to the memory, the processor has to stop running. Can have severe implications on any program with timing operations.
Then the program memory on these chips is 14bits wide (accessed as two bytes). So you can't store two bytes in two locations, but would need three or four locations to store a two byte value.
Writes are 'word oriented' on this chip, with a write to an entire 14bit word needed to cause an erase.
Now, if you just want to store strings, have you looked at the data EEPROM?. Though only 128byte in size, this supports 100K write cycles (100* better), & doesn't stop code execution to write. Given a 'string' is just a null terminated array of integers, and this stores integers, rather simple....
As Gabriel has pointed out the compiler contains automatic systems to allow constant values to be stored in the program memory. Realistically, use this with some care, and you may manage to save enough RAM. Also, you have presumably got #DEVICE *=14 or *=16 near the start of your program?. Otherwise you will only have access to just over half the actual RAM.
Trying to use the program memory for anything approaching a 'variable' is just something you should not do. Consider a chip with more RAM instead....
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|