#include #include #include unsigned char i, j, k, m, n, dat1, dat2, dat3, dat4, hbyte[20], lbyte[20]; unsigned char dat1a, dat2a, dat3a, dat4a; void main(void) { while(1) { RCSTA=0b10010000; //enable serial port, enable continuous read TXSTA=0b00100100; //transmit enabled, asyncronous, high speed mode SPBRG=20; //baud rate = 56K OPTION=0b00000000; TRISA=0b00000001; //set A0 as an input port ADCON1=0b10001110; //right justified,fast speed,only A0 is A2D ADCON0=0b00000001; //fast speed, channel A0, turn A2D on for (j=1;j<20;j++) { ADCON0=0b00000101; //initiate A2D on channel A0 while((ADCON0 & 0b00000100) == 4) {}; //wait till A2D is done hbyte[j]=ADRESH; //capture high bytes lbyte[j]=ADRESL; //capture low bytes } for (j=1;j<20;j++) { while((PIR1 & 0b00010000)==0){}; //wait till serial port is cleared TXREG=hbyte[j]; //transfer high byte for(i=1;i<3;i++) {} //wait some time while((PIR1 & 0b00010000)==0){}; TXREG=lbyte[j]; for(i=1;i<3;i++) {} } } }