Hello, I am starting with a first programm to test a AD-conversion.After the compiling to a HEX-file I do test the programm in REAL PIC SIMULATOR.
But nothing works, I do not see a AD value for the 2 ports !! I think even the hex file is not correct ! please help me, what is wrong ?? Here is my program:
Code:'* Name : ADtest16F684.BAS * '* Date : 10-5-2015 * '**************************************************************** #config __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF #ENDCONFIG Define OSC 4 ' Match the crystal on the board OSCCON = %01100101 'select intern clock 4 Mhz TRISA = %00111111 'all inputs TRISC = %00000000 'all outputs Define ADC_bits 8 define ADC_sampleus 100 ADCON1 = %00110000 'interne ad-clock is ook define ad_clock 3 ADCON0 = %11001001 'normal left justified channel AN2= enabled define ADC_CLOCK 3 'werkt misschien niet CMCON0 = 7 'comparators off CxIN pins are dig I/O PORTC.0 = 0 : PORTC.1 = 0:PORTC.2 = 0 PORTC.3 = 0 : PORTC.4 = 0:PORTC.5 = 0 shortad var WORD 'is de ingang AN0 longad var word 'is de ingang AN1 ANSEL = %00000100 'kies RA2 als analoog ingang pause 10 ADCIN 2,shortAD 'short is 0 - 255 van AD shortAD ingang AN0 pause 100 ADCON0 = %11010001 'normal left justified channel AN4= enabled ANSEL = %00010000 'kies RA4 als analoog ingang pause 10 adcin 4,longAD 'long is 0 - 255 van AD longAD ingang AN1 pause 100 'shortAD = 138 PORTC.5 = 1 if shortAD < 45 then PORTC.0 = 1 : goto x7 if shortAD < 90 then PORTC.1 = 1 : goto x7 if shortAD < 135 then PORTC.2 = 1 : goto x7 if shortAD < 180 then PORTC.3 = 1 : goto x7 if shortAD < 215 then PORTC.4 = 1 : goto x7 PORTC.5 = 1 x7: end





Bookmarks