My code is as follows:
I am trying to take adc reading of a POT, but the result is constantly "B0=010" on my LCD. Could someone help me identify the problem please?Code:Include "modedefs.bas" DEFINE OSC 20 ' OSCCON defaults to 4MHz on reset DEFINE ADC_BITS 8 ' Set number of bits in result (8, 10 or 12) DEFINE ADC_SAMPLEUS 50 ' Set sampling time in microseconds ;-------------CONFIGURATION FUSES SET HERE------------------------- @ __Config _RC_OSC & _WDT_ON & _PWRTE_ON & _BODEN_ON ; & _CP_ALL DEFINE LCD_DREG PORTB DEFINE LCD_DBIT 0 DEFINE LCD_RSREG PORTB DEFINE LCD_RSBIT 4 DEFINE LCD_EREG PORTB DEFINE LCD_EBIT 5 DEFINE LCD_BITS 4 DEFINE LCD_LINES 2 DEFINE LCD_COMMANDUS 2000 DEFINE LCD_DATAUS 50 PAUSE 100 ;------------REGISTERS SET HERE------------------------ ADCON1=%00000100 ADCON0=%1100000 PORTA=0 PORTB=0 PORTC=0 TRISA = %000001 TRISC = 0 TRISB = 0 OPTION_REG = %10001111 ' RAPU = off, PS 1:256 to TMR0 PORTA=0 PORTC=0 PORTB=0 B0 Var Word gosub CLER start var Adcon0.0 done var Adcon0.2 Main: Start=1 while done=1 : pause 1 : wend b0=ADRES LCDOUT $FE,2," B0=",dec3 B0 : pause 500 GOSUB CLER goto Main cler: LCDOUT $FE,1 pause 10 LCDOUT $FE,2 PAUSE 10 LCDOUT $FE,$0C pause 100 return




Bookmarks