I have Set these bits in my program but still the port pins are pulled up.
I have Set these bits in my program but still the port pins are pulled up.
What is your analog source?
Can you post a schematic and your current code?
Dave
Always wear safety glasses while programming.
I have already posted the code.Analog source is simply a pot for 1-5V range.
Hello hell_pk,
Try adding OPTION_REG.7 = 0 to the upper area of you code.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
I have added the line but still no result.very strange.
i have configured all registers ANSEL,WUPA etc in program.
What am I missing!!!
You have all the inputs as digital inputs ANSEL = $00 Shouldn't A0 be an analogue input?
Adrian
Out of curiosity, which compiler version are you using?
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Post #1 shows a lot of things but it is difficult to tell where the code is or the things you hace tried. Post your current code in tags like Mr.E suggest.
You have ANSEL set two different ways in post #1. Is that the way you have it in your code?
Did you read and try post #2? Some of the registers PBP handles for you when using ADCIN.
Dave
Always wear safety glasses while programming.
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
Try commenting out these lines
I think they may be causing a conflict.Code:ADCON1=%01110000 PORTA=$00 ADCON0=%00000001
Dave
Always wear safety glasses while programming.
Still no luck.The Analog channel pulls up before ADCIN command therefore something must be wrong with register configs.
very frustrating!
Bookmarks