avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] how to write specific value to program memory?


From: David Kelly
Subject: Re: [avr-gcc-list] how to write specific value to program memory?
Date: Thu, 24 Nov 2005 10:36:12 -0600


On Nov 24, 2005, at 6:49 AM, 임지수 wrote:

hi,

I am using atmega128 mic.
i want program memory to store data, not eeprom.
At avrlibc, the file of pgmspace.h provide the function to read the program memory.
But I can't find the function to write the program memory.
how to write specific value to program memory?

Its hard to write to FLASH program memory so its not done very often other than to write executable code and constant data. Also in general FLASH memory can not be reprogrammed as many times before breaking than EEPROM cells.

EEPROM is much easier to write but harder to read than FLASH because the AVR EEPROM is not in either of the CPU memory spaces. The solution I use for read-often variables is to declare a structure containing all my EEPROM variables. Then create two allocations of that structure, one in RAM and one in EEPROM. Usually call them ee and wc, for EEprom and Working Copy, that its obvious ee.calibration and wc.calibration are paired.

Initialization is easy because one only has to bulk copy ee into wc. Is also practical to bulk copy wc into ee, but I selectively write my updates as needed.

--
David Kelly N4HHE, address@hidden
========================================================================
Whom computers would destroy, they must first drive mad.







reply via email to

[Prev in Thread] Current Thread [Next in Thread]