/* EEPROM.c: Writes a value to the EEPROM and shows it on the monitor. Compiler: BC++ 3.1, Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum) MSC 6.0, MSVC 1.52. Compile mode: Large Project: EEPROM.c ..\..\Lib\(8000E.Lib,7188XAL.Lib,7188XBL.Lib,7188XCL.Lib or 7188EL.Lib) Hardware: 7188/8000 Detail description: Following list is where the user should avoid to write to For 7188XA/B/C ==> block 7 For 7188E(Xserver) ==> block 0, 7 For 7188E-MTCP ==> block 0,1,2,3,7 For 8x1x ==> block 7 For 8x3x (Xserver) ==> block 0,7 For 8000E-MTCP ==> block 0,1,2,3,7 [May,13,2005] by Kevin [05/Dec/2006] by Liam [July,13,2011] by Nicholas */ #include "..\..\lib\7188e.h" void main(void) { int iBlock,iAddress,iRet,iValue,iByte; float fValue; InitLib(); /*===== For integer =====*/ Print("Writes 3 integers (1234,7188,8000) to block 1.\n\r"); EE_WriteEnable(); iValue=1234; iRet=EE_MultiWrite(1,0,2,(char*)&iValue); /* block 1, address 0, 2 bytes */ iValue=7188; iRet=EE_MultiWrite(1,2,2,(char*)&iValue); /* block 1, address 2, 2 bytes */ iValue=8000; iRet=EE_MultiWrite(1,4,2,(char*)&iValue); /* block 1, address 4, 2 bytes */ EE_WriteProtect(); Print("Gets 3 integers from block 1.\n\r"); iRet=EE_MultiRead(1,0,2,(char*)&iValue); /* block 1, address 0, 2 bytes */ Print(" Block 1, Address 0 = %d\n\r",iValue); iRet=EE_MultiRead(1,2,2,(char*)&iValue); /* block 1, address 2, 2 bytes */ Print(" Block 1, Address 2 = %d\n\r",iValue); iRet=EE_MultiRead(1,4,2,(char*)&iValue); /* block 1, address 4, 2 bytes */ Print(" Block 1, Address 4 = %d\n\r",iValue); Print("Clears the 3 integers.\n\r"); EE_WriteEnable(); iValue=1234; iRet=EE_MultiWrite(1,0,2,(char*)&iValue); /* block 1, address 0, 2 bytes */ if(iRet!=NoError) Print("Clears block 1, address 0 ===> error !\n\r"); iRet=EE_MultiWrite(1,2,2,(char*)&iValue); /* block 1, address 2, 2 bytes */ if(iRet!=NoError) Print("Clears block 1, address 2 ===> error !\n\r"); iRet=EE_MultiWrite(1,4,2,(char*)&iValue); /* block 1, address 4, 2 bytes */ if(iRet!=NoError) Print("Clears block 1, address 4 ===> error !\n\r"); EE_WriteProtect(); Print("Press any key to continue.\n\r\n\r"); Getch(); /*===== for float values =====*/ Print("Writes 3 float values (1234.123, 7188.123, 8000.123) to block 1.\n\r"); EE_WriteEnable(); fValue=1234.123; iRet=EE_MultiWrite(1,0x10,4,(char*)&fValue); /* block 1, address 0x10 */ fValue=7188.123; iRet=EE_MultiWrite(1,0x14,4,(char*)&fValue); /* block 1, address 0x14 */ fValue=8000.123; iRet=EE_MultiWrite(1,0x18,4,(char*)&fValue); /* block 1, address 0x18 */ EE_WriteProtect(); Print("Gets 3 float values from block 1.\n\r"); iRet=EE_MultiRead(1,0x10,4,(char*)&fValue); /* block 1, address 0x10, 4 bytes */ Print(" Block 1, Address 10(hex) = %7.3f\n\r",fValue); iRet=EE_MultiRead(1,0x14,4,(char*)&fValue); /* block 1, address 0x14, 4 bytes */ Print(" Block 1, Address 14(hex) = %7.3f\n\r",fValue); iRet=EE_MultiRead(1,0x18,4,(char*)&fValue); /* block 1, address 0x18, 4 bytes */ Print(" Block 1, Address 18(hex) = %7.3f\n\r",fValue); Print("Clears the 3 float values.\n\r"); EE_WriteEnable(); fValue=0.0; iRet=EE_MultiWrite(1,0x10,4,(char*)&fValue); /* block 1, address 0x10 */ if(iRet!=NoError) Print("Clears block 1, address 10(hex) ===> error !\n\r"); iRet=EE_MultiWrite(1,0x14,4,(char*)&fValue); /* block 1, address 0x14 */ if(iRet!=NoError) Print("Clears block 1, address 14(hex) ===> error !\n\r"); iRet=EE_MultiWrite(1,0x18,4,(char*)&fValue); /* block 1, address 0x18 */ if(iRet!=NoError) Print("Clears block 1, address 18(hex) ===> error !\n\r"); EE_WriteProtect(); Print("Press any key to continue.\n\r\n\r"); Getch(); /*===== for bytes =====*/ Print("Writes 3 bytes ('A', 'B', 'C') to block 1.\n\r"); EE_WriteEnable(); iRet=EE_RandomWrite(1,0x20,'A'); /* block1, address 0x20, byte='A' */ iRet=EE_RandomWrite(1,0x21,'B'); /* block1, address 0x21, byte='B' */ iRet=EE_RandomWrite(1,0x22,'C'); /* block1, address 0x22, byte='C' */ EE_WriteProtect(); Print("Gets 3 bytes from block 1.\n\r"); iByte=EE_RandomRead(1,0x20); Print(" Block 1, Address 20(hex) = %c\n\r",iByte); iByte=EE_RandomRead(1,0x21); Print(" Block 1, Address 21(hex) = %c\n\r",iByte); iByte=EE_RandomRead(1,0x22); Print(" Block 1, Address 22(hex) = %c\n\r",iByte); Print("Clears the 3 bytes.\n\r"); EE_WriteEnable(); EE_RandomWrite(1,0x20,'_'); if(iRet!=NoError) Print("Clears block 1, address 20(hex) ===> error !\n\r"); EE_RandomWrite(1,0x21,'_'); if(iRet!=NoError) Print("Clears block 1, address 21(hex) ===> error !\n\r"); EE_RandomWrite(1,0x22,'_'); if(iRet!=NoError) Print("Clears block 1, address 22(hex) ===> error !\n\r"); EE_WriteProtect(); }