/* Flash-w.c: 1. To write an integer which you input to segment 0x9000, offset 0 of Flash memory. 2. The integer you input will be written to Flash memory and increase by 1. Compiler: BC++ 3.1, Turbo C++ 1.01 (3.01) MSVC 1.52 Compile mode: Large Project: Flash-w.c ..\..\Lib\upac5000.lib Hordware: uPAC-5000 Description The uPAC-5000 module contains 512K bytes of Flash memory which includes spaces reserved for the MiniOS7. The MiniOS7 occupies the 0xF000 segment. So user can use the other segments whose total size is 448K bytes. Each bit of the Flash can only be written from 1 to 0 and cannot be written from 0 to 1. The only way to change the data from 0 to 1 is to call the EraseFlash() function to erase a segment. [Dec 28, 2011] by Liam */ #include #include #include #include "..\..\lib\upac5000.h" void main(void) { int seg, data; char c; unsigned e=0x9000, i=0; InitLib(); Print("\r\nPlease Input a value writting to segment 0x9000 of Flash memory: "); Scanf("%d", &seg); FlashErase(e); while(i<65535) { FlashWrite(e, i, seg); Print("\r\nThe value %d is writting to offset %d of Flash memory", seg, i); i++; seg++; if(i%100==0) { Print("\r\nPress 'q' to quit or any key to continue..."); c=Getch(); if((c=='q') || (c=='Q')) return; } } }