CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

how to use program memory as data memory in pic16f877a

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
thangapandi



Joined: 27 Aug 2012
Posts: 6
Location: Madurai

View user's profile Send private message

how to use program memory as data memory in pic16f877a
PostPosted: Thu Sep 06, 2012 2:36 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Sep 06, 2012 6:29 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Sep 13, 2012 4:20 am     Reply with quote

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: 19369

View user's profile Send private message

PostPosted: Thu Sep 13, 2012 7:41 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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