Compiler ver 2.50
Code:Define ADC_BITS 8 ' Set number of bits in result Define ADC_CLOCK 3 ' Set clock source (3=rc) Define ADC_SAMPLEUS 50 ' Set sampling time in uS OPTION_REG.7 = 0 PORTC=0 CMCON0=$07 'CMCON0=$00 ANSEL=$01 TRISA=$01 TRISC=$00 WPUA=$00 'OSCCON=%1110111 'configure ADC ADCON1=%01110000 PORTA=$00 ADCON0=%00000001 adval var word ' Create adval to store result Res Var word ' Define LCD registers and bits Define LCD_DREG PORTC Define LCD_DBIT 0 Define LCD_RSREG PORTC Define LCD_RSBIT 4 Define LCD_EREG PORTC Define LCD_EBIT 5 DEFINE LCD_BITS 4 Lcdout $fe,1 loop: ADCIN 0, adval Res = 2*adval Pause 300 Lcdout $fe, $80 Lcdout "T:", DEC2 Res,"C" 'text for the line 1 Lcdout $fe, $80+8 ,#Res Lcdout $fe, $C0 'set cursor at the beginning of line 2 Lcdout "V: ", #adval 'formatted text for line 2 Pause 300 goto loop




Bookmarks