The Godfather talking
You think I am funny guy huh?
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 08, 2016, 08:50:26 08:50


Login with username, password and session length


Pages: [1]
Print
Author Topic: How can I save some variable to Program Memory?  (Read 4291 times)
0 Members and 1 Guest are viewing this topic.
modafox
Guest
« on: September 19, 2008, 08:45:32 08:45 »

I'm using PIC24FJ48 with MPLAB C30.
I want to save the data to flash (Program Memory section) and read it back when new power up.

Does anyone know how to do this?

Thanks.
Logged
maddoc
Newbie
*
Offline Offline

Posts: 32

Thank You
-Given: 49
-Receive: 14


« Reply #1 on: September 19, 2008, 09:26:51 09:26 »

It is not advisable to do that, if you expect frequent power cycling then it is better to add an eeprom to the design.
The flash wears out quick and those variables won't get stored anymore.
Logged
BharatSujanani
Junior Member
**
Offline Offline

Posts: 42

Thank You
-Given: 24
-Receive: 18

All is Well


« Reply #2 on: June 27, 2009, 01:39:19 13:39 »

I have done this thing in 18f452.
You can save data to flash by declaring variables as a const rom variables.
As a ex.
const rom unsigned char temp=25;
And you can read it by function
void *memcpypgm2ram (auto void *s1, auto const MEM_MODEL rom void *s2, auto sizeram_t n);
Information about this function is available in string.h file of your compiler.
Logged

Bharat Sujanani
TomJackson69
V.I.P
Active Member
*****
Offline Offline

Posts: 221

Thank You
-Given: 23
-Receive: 63


« Reply #3 on: June 28, 2009, 01:05:00 01:05 »

modafox ,

If you only read the data then storing in the program memory is ok, but to write and rewrite for later use is not a good pratice because, the flash memory is only cappable for write so many cycles. Use EEPROM is better but still depends on how often you write to the EEprom.

Tom
Logged

Con Rong Chau Tien
ALLPIC
V.I.P
Active Member
*****
Offline Offline

Posts: 113

Thank You
-Given: 64
-Receive: 72


« Reply #4 on: June 28, 2009, 12:40:48 12:40 »

I used such think previously and working no problem, as every one telling you flash write is not good but if you keep track on 1000 write cycle then that work properly

please find attachment this code I found from Microchip web site and seams working good from last 1 year  Wink

i think this will help you  Smiley

regards
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC