[En-Nut-Discussion] function to write data into flash memory
Dusan Ferbas
dferbas at etech.cz
Sat Feb 17 15:36:25 CET 2007
Hi,
I suggest e.g. following, which was digged from eboot\tftp.c.
Checking for full page and stuffing is done in upper layer. For
Spm... functions use eboot\flash.* files. Note: we renamed SPMCR to
SPMCSR in flash.s and also changed 0 (argument) to SPMEN macro.
void FlashPage(unsigned short page, unsigned short *data, unsigned short len)
{
unsigned short i;
// if (len > 256)
// len = 256;
if (page >= 256) {
RAMPZ = 1;
} else
RAMPZ = 0;
page <<= 8;
SpmCommand(page, _BV(PGERS) | _BV(SPMEN));
SpmCommand(0, _BV(RWWSRE) | _BV(SPMEN));
for (i = 0; i < len; i += 2)
SpmBufferFill(i, *data++);
SpmCommand(page, _BV(PGWRT) | _BV(SPMEN));
SpmCommand(0, _BV(RWWSRE) | _BV(SPMEN));
}
At 18:19 15.2.2007, you wrote:
>No problem.
>
>The same question I wrote in AVR-LIBC-DEV discussion. There I get
>the answer by Eric Weddington (Atmel) that I can use the bootloader
>functions (See <avr/boot.h>).
>
>Thomas
>
>Mustafa Yuecel schrieb:
>>Sorry for the wrong information. I see now that even uromfs does not
>>implement any write function...
>>
>>Thomas Richter wrote:
>>>Hi Mustafa,
>>>
>>>thanks for answer.
>>>
>>>I have checked the avr-libc and the program space utilities yet. But all
>>>functions in the lib only have functionality for reading from program
>>>space.
>>>In the EEPROM handling and Bootloader Support Utilities there are
>>>reading and writing functions. I do not understand why the program space
>>>utitities do not have writing functions.
>>>
>>>My aim is to write data into flash.
>>>
>>>Regards,
>>>Thomas
>>
>>Dusan
More information about the En-Nut-Discussion
mailing list