A SERVICE OF

logo

iVIEW-100 Series user’s Manual, 2006, v2.0 ----- 128
FlashWrite()
Func.: Write one byte data to FLASH.
Syntax:
int FlashWrite(unsigned int seg, unsigned int offset, char data);
Header: #include ”iVIEW.h”
Description:
seg: 0x8000, 0x9000, 0xA000, 0xB000, 0xC000, 0xD000 or 0xE000.
offset: 0 to 65535(0xffff).
data: 0 to 255(8-bit data).
Return NoError(0) on success.
Return TimeOut(-5) or SegmentError(-12) on fail.
Note:
When write data to Flash Memory, data bit only can be changed from 1
to 0. So if data in the position of 0xff, you can write any data to it.
But if data in
the position of 0x01, you can only write 0x00 to it. FlashWrite do not check it,
and just write it. When you want to change data from 0 to 1,
you will get
TimeoutError. After call FlashErase you can write any data to it again.
Example:
(flashm.c)
#include <iVIEW.H>
#include <mmi100.H>
void main()
{
int data=0xAA55, data2;
char *dataptr;
InitLib();
dataptr=(char *)&data;
//write data to Flash memory
FlashWrite(0xd000,0x1234, *dataptr++);
FlashWrite(0xd000,0x1235, *dataptr);
//read data from Flash memory
dataptr=(char *)&data2;
*dataptr=FlashRead(0xd000, 0x1234);
*(dataptr+1)=FlashRead(0xd000, 0x1235);
}
FlashRead()
Func.: Read one byte data from FLASH.
Syntax:
int FlashRead(unsigned int seg, unsigned int offset);
Header: #include ”iVIEW.h”
Description:
seg: 0-65535(0xffff).
offset: 0 to 65535(0xffff).
Return Value: FlashRead just return the value on address seg:offset. The
address can be on SRAM, Flash memory or other address (generally return
0xff).
Example: Please refer to “FlashWrite()” for detail information.