/* topmem.c: Demonstration of the AllocateTopMemory() function. Compiler: BC++ 3.1, Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum) Compile mode: Large Project: topmem.c ..\..\lib\7188e.lib Hordware: 7188E Note: download topmem.exe to Flash and run it, will get: i7188E>run addr=3FF9:0000 First time run the program(topmem.exe) set data flag and set data to "0x12 0x34 0xAB 0xCD" Wait WDT to reset system... i7188E>run <--- after system reset by WDT, run it again addr=3FF9:0000 Find last data flag data:0x12 0x34 0xAB 0xCD <--- the data saved before system reset by WDT will not lost. i7188E>mcb 03F2:0000 -> |* Free *| type ='M'; m_psp=0x0000; m_size=0x3c05(15365)[245840] 3FF8:0000 -> | | type ='Z'; m_psp=0xffff; m_size=0x0007(7)[112] i7188E> [05/Dec/2006] by Liam [July,13,2011] by Nicholas */ #include "..\..\lib\7188e.h" void main(void) { unsigned char far *data=AllocateTopMemory(100); if(data) { Print("addr=%Fp\n\r",data); if(data[0]==0x71 && data[1]==0x88) { Print("Find last data flag\n\r"); Print("data:0x%02X 0x%02X 0x%02X 0x%02X\n\r", data[2],data[3],data[4],data[5]); } else { Print("First time run the program(topmem.exe)\n\r"); Print("set data flag and set data to \"0x12 0x34 0xAB 0xCD\"\n\r"); data[0]=0x71; data[1]=0x88; data[2]=0x12; data[3]=0x34; data[4]=0xAB; data[5]=0xCD; Print("Wait WDT to reset system..."); EnableWDT(); for(;;) ; } } else { Print("Allocate memory error!"); return; } }