di2822l2.txt ;**************************************************************************************************** ; LISTING 2 - PHOTOGATE-SUPPORT PROGRAM ; ; "Extend the timing capabilities of a PC," EDN, Jan 10, 2002, pg 76 ; ;************************************************************************************************** #include #include #include #include /* SIGNAL* is not connected but reserve Pin 3 (D1) and A3 on PIC power to PIC through VDD_ON on pin 6 (D4) power to LED and transistor wiht TRANS_ON/LED_on pin 4 (D2) MCLR* on pin 5 (D3) normally high NORMAL OPERATION with Power and not reset (i.e. go) OR with POWGO (0x1C) The MSB of the printer Status port (S7*) or Pin 11 is used as input data Pin 10 (S6) is VALID signal from PIC that data is valid on Pin 11 Pin 2 (D0) is SEND signal to PIC that PC is ready to receive HAS BASIC CONVERSION ONLY 5 microsec per step */ #define DELAY 320 /* timing delay 320 for 166Pentium, 4Mhz */ #define TIMES 640000*16 /* length of time pulse if used */ #define SIGNAL 0x02 #define SEND 0x01 #define POWGO 0x1C #define BYT 4 /*total number of bytes of data */ #define BIT 8 /*bits in 1 byte */ void main(void) { int dport_lpt1, sport_lpt1, bit, byt, columns, rows; unsigned char shift_reg[BYT],temp; char c; long i,itemp; float tempus; /*Get LPT1 port addresses */ if(!(dport_lpt1 = peek(0x40,0x08))) { printf("\n\n\nLPT! not available... aborting\n\n\n"); exit(1); } sport_lpt1 = dport_lpt1 + 1; /* status port address */ /* Initialize the Printer DATA Port both for timing and SEND=0 */ outportb(dport_lpt1,0x00|POWGO); /* Generate timing SIGNAL */ #undef USE_SIGNAL #ifdef USE_SIGNAL outportb(dport_lpt1,SIGNAL|POWGO); for(i=0;i>= 1; /* shift bit one right */ shift_reg[byt] &= 0x7f; /* make MSB 0 */ shift_reg[byt] |= temp; /* new bit in MSB */ for(i=0;i