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 CCS Technical Support

Send data to PIC over RS232 and store in ROM

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



Joined: 12 Feb 2016
Posts: 11

View user's profile Send private message

Send data to PIC over RS232 and store in ROM
PostPosted: Mon Feb 15, 2016 11:13 pm     Reply with quote

Hi

I have a small hobby project that involves PIC reading ADC value through multiple multiplexers then sending the reading to PC via RS-232. The program so far works.

But I also need to send data (an integer) over RS-232 from PC to PIC, and whatever this value I sent must replace the existing integer variable's value and retain the sent integer even after the PIC turned off.

For instance:

Code:

unsigned int8 WaterLevel_Tank1;
unsigned int8 WaterLevel_Tank2;
unsigned int8 WaterLevel_Tank3;

void main() {
   // Initialise default value;
   WaterLevel_Tank1 = 7;
   WaterLevel_Tank2 = 2;
   WaterLevel_Tank3 = 20;

   while(1) {
      // Codes for reading ADC and sending ADC value to PC

      // Incoming serial data says 'replace WaterLevel_Tank1 value to 1'
      WaterLevel_Tank1 = 1;
      // Now need to make this change permanent, maybe write to ROM? How?
   }
}


The only way I can think of is add an EEPROM to store this new value of 1 for WaterLevel_Tank1, and let PIC poll for changes every now and then.

But is there a way without adding EEPROM?

I'm using PIC16F1527 and compiler version v5.045.

Thank you.
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Mon Feb 15, 2016 11:36 pm     Reply with quote

Well, according to the data sheet for that chip, it has
High-Endurance Flash Data Memory (HEF)
- 128B of nonvolatile data storage
- 100K erase/write cycles

which would probably support what you want to do. See the chip data sheet at http://ww1.microchip.com/downloads/en/DeviceDoc/40001458D.pdf
See pg 17 "Memory Organization" which provides some additional information about HEF memory in that location.
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Feb 16, 2016 6:46 am     Reply with quote

Two other options

1) Use an RTC like the DC1307 and store the data in it's RAM buffer. Should be good for 5-8 years. Having a hardware RTC could be 'nice'.

2) Add a 'super cap' to the PIC's power supply NOT the board supply. You need to isolate the PIC from everything else and have a 'main power off' indicator to put PIC in 'very low power mode'.

Which is best is up to you as you kow how long PIC will be 'off' as wellas othr 'system parameters'.

Jay
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