/* * Measure the time required for the sensor circuit to properly reset. */ #include void handle(void); char data[72]; int index; unsigned int mscount; char n, i, j, ms; void main (void) { VIA2_DDRA = 0xff; VIA1_DDRB |= 0x20; irq_handler = handle; VIA1_ACR &= 0x3f; VIA1_ACR |= 0x40; /* 1ms */ VIA1_T1L_L = 0xe8; VIA1_T1C_H = 0x03; VIA1_IER = 0xc0; asm("cli"); while (index < sizeof(data)) { for (n=1; n; n <<= 1) { data[index] = 0xcc; ++index; data[index] = n; ++index; data[index] = 0x00; ++index; data[index] = n; ++index; data[index] = 0xcc; ++index; #if 0 Port2A = 0x01; /* See how long it takes this one to turn off */ mscount = 0; do { ms = 0; while (!ms) ; #if 0 if (! (Port1B & 0x80)) { #else if (! (Port1B & 0x10)) { #endif goto bbbreak; } ++mscount; } while (1); bbbreak: data[index] = mscount >> 8; ++index; data[index] = (char) mscount; ++index; #else index += 2; #endif Port2A = n; mscount = 0; do { ms = 0; while (!ms) ; #if 0 if (! (Port1B & 0x80)) { #else if (! (Port1B & 0x10)) { #endif goto bbreak; } ++mscount; if (mscount == 1000) { goto bbreak; } } while (1) ; bbreak: data[index] = mscount >> 8; ++index; data[index] = (char) mscount; ++index; } } asm("cli"); while (1) { for (i = 0; i < 75; ++i) ; Port1B ^= 0x20; } } void handle (void) { asm("inc _ms"); asm("lda #$40"); asm("sta _VIA1_IFR"); }