#include #include #include "..\..\lib\7188.h" /* ------------------------------------------------------------------- */ void main() { int i,i1,i2,j,val,t; char c; InitLib(); /* driver initial */ InstallCom(1,57600L,8,0,1); /* COM1, RS-232, full-duplex mode, INT */ /* Note : JP1 must select RS-232 */ InstallCom(3,57600L,8,0,1); /* COM3, RS-232, full-duplex mode, INT */ /* COM4, RS-232, connect to PC's COM port for download */ EnableEEP(); /* enable for write operation */ for (j=0; j<8; j++) /* write initial value to all 1K bytes data */ for (i=0; i<256; i+=16) { WriteEEP(j,i,i+j); t=ReadEEP(j,i); printf("\nWrite EEPROM : block=%x,addr=%x,data=%x",j,i,t); if (t!=((i+j)&0xff)) printf("\7"); } printf("\n"); ProtectEEP(); /* protect data in EEPROM */ for (i=0; i<31; i++) { WriteNVRAM(i,i); t=ReadNVRAM(i); /* read back NVRAM for check */ printf("\nWrite NVSRAM : addr=%x,data=%x",i,t); if (i!=t) printf("\7"); } Init5DigitLed(); /* initial & blank the 5-digit LED */ i1=i2=0; j=0; DelayMs(500); printf("\nStart to test COM3/COM1 RS-232 test"); for (;;) { LedOn(); ToCom(3,0x5A); i=0; while (IsCom(1)==0) { i++; if (i>30000) printf("\nCOM3 send 5A --> COM1 no respons"); goto next_2; } val=ReadCom(1); printf("\nCOM3 send 5A --> COM1 receive %x",val); next_2: ToCom(3,0xA5); i=0; while (IsCom(1)==0) { i++; if (i>30000) printf("\nCOM3 send A5 --> COM1 no respons"); goto next_3; } val=ReadCom(1); printf("\nCOM3 send A5 --> COM1 receive %x",val); next_3: DelayMs(500); LedOff(); ToCom(1,0x5A); i=0; while (IsCom(3)==0) { i++; if (i>30000) printf("\nCOM1 send 5A --> COM3 no respons"); goto next_4; } val=ReadCom(3); printf("\nCOM1 send 5A --> COM3 receive %x",val); next_4: ToCom(1,0xA5); i=0; while (IsCom(3)==0) { i++; if (i>30000) printf("\nCOM1 send A5 --> COM3 no respons"); goto next_5; } val=ReadCom(3); printf("\nCOM1 send A5 --> COM3 receive %x",val); next_5: if (kbhit()) /* is user press PC's keyboard from COM4 */ { c=getch(); /* if this key is Q or Q --> exit this program */ if ((c=='q') || (c=='Q')) { RestoreCom(1); RestoreCom(3); return; } } DelayMs(500); } }