// Test system sound, LEDs and EEPROMs on MicroBoard // Caution: This test will overwrite all the data in EEPROMs! #define E2PROM_24 24 #define E2PROM_93 93 #define MAX_ADDR_24 255 #define MAX_ADDR_93 255 #define DELAY 2000 #define SPK 12 main() { int i; writes("sys test", DELAY); sound(SPK, 500, 1000); sound(SPK, 800, 1000); pinhigh(SPK); for(i=0; i < 20; i++) { pinlow(i); delay(200); pinhigh(i); } writes("test 24c", DELAY); if(test_eeprom(E2PROM_24, MAX_ADDR_24)) writes("24c bad", DELAY); else writes("24c good", DELAY); writes("test 93c", DELAY); if(test_eeprom(E2PROM_93, MAX_ADDR_93)) writes("93c bad", DELAY); else writes("93c good", DELAY); } test_eeprom(eeprom, max_addr) { int d, addr, fail; for(addr=0; addr <= max_addr; addr++){ writei('d', addr, 10); writem(eeprom, addr, d); if(readm(eeprom, addr) != d) fail = 1; d++; d %= 128; // keeps data value in range 0..127 } return(fail); }