#include "Xbus.h" #include #include #define ZERO 0x77 #define ONE 0x12 #define TWO 0x5d #define THREE 0x5b #define FOUR 0x3a #define FIVE 0x6b #define SIX 0x6f #define SEVEN 0x52 #define EIGHT 0x7f #define NINE 0x7b #define ERROR 0x6d void PCReset() { IE = 0x00; /* no interrupts */ P0 = 0xff; /* tristate (not pull down) the port */ P1 = 0xff; /* tristate (not pull down) the port */ P2 = 0xff; /* tristate (not pull down) the port */ P3 = 0xff; /* tristate (not pull down) the port */ } // Pins for debugging sbit NOSRAM = 0xB0; /* error pin is P3.0 */ sbit SRAM = 0xB2; /* noerror pin is P3.2 */ sbit DONE = 0xB3; /* noerror pin is P3.3 */ void main() { unsigned char value = 0x01; unsigned char back = 0x00; long i; PCReset(); XInit(); NOSRAM = 0; SRAM = 0; DONE = 0; value = ZERO; while (1) { // all programs run forever XWrite(0x7fff, value); // write new data to the led back = XRead(0x7fff); //read back the data if(back != value) { value = ERROR; } else { switch (back) { case ZERO: value = ONE; break; case ONE: value = TWO; break; case TWO: value = THREE; break; case THREE: value = FOUR; break; case FOUR: value = FIVE; break; case FIVE: value = SIX; break; case SIX: value = SEVEN; break; case SEVEN: value = EIGHT; break; case EIGHT: value = NINE; break; case NINE: value = ZERO; break; } } for (i=0; i < 20000; i++); // wait } }