di2495.txt ;*************************************************************************************************** : LISTING 1 - HANDLER ROUTINE FOR A/D CONVERSION ; ; "BIOS interrupt performs A/D conversion," EDN, March 16, 2000, pg 148 ; ; http://www.ednmag.com/ednmag/reg/2000/031600/designideas.htm#06di5 ;************************************************************************************************** /* Program for an 8-bit ADC using PC's interrupt INT1ch and parallel port. Counter-ramp technique Author: J.Jayapandian, MSD, IGCAR, Kalpakkam, Tamil Nadu. INDIA */ #include #include #include #define OUT_PORT 0X378 /* Out port address of LPT2 */ #define CTRL_PORT 0X37A /* Control port address of LPT2 */ #define INTRTIMER 0x1C /* BIOS Timer (INT 1CH)Interrupt */ /*----------------------------------------------------------------------*/ /*-------------------------GLOBAL VARS----------------------------------*/ static int ADC_value,STATUS; static int TICKER; int i = 0; void interrupt (*timerhandler)(); void interrupt ADCHANDLER(); /*----------------------------Handler routine for INT 1C---------------*/ void interrupt ADCHANDLER() { disable(); ++TICKER; for(i=0; i<256; i++) { outportb(OUT_PORT,i); ADC_value = i; } STATUS = inportb(OUT_PORT) & 0x01; enable(); } /* END OF ADCHANDLER */ void INSTALLADCHANDLER() { disable(); timerhandler = getvect(INTRTIMER); setvect(INTRTIMER,ADCHANDLER); enable(); } void CLEARADCHANDLER() { disable(); setvect(INTRTIMER,timerhandler); */ enable(); } void main(void) { clrscr(); outportb(CTRL_PORT,0x01); INSTALLADCHANDLER(); while (STATUS != 0x01); printf("ADC value is %x\n",ADC_value); CLEARADCHANDLER(); //getch(); /* For testing this can be included */ return; } / *----------------------- End of Program -----------------------*/