Page 1 of 1
Having problem to declare AN pins with 18F2620
Posted: 06 Jun 2010 21:31
by crocu
Hello,
I'm using 18F2620 and i need to use 4 x analog inputs : RA0 - RA1 - RA2 - RA3
I declared ANCON1 as follow but it won't work :
Code: Select all
ADCON1 = 0x0E; // Set AN0 to AN3 as analog channels
ADCON1= 0x82; // configure VDD as Vref, and analog channels
It compiles with no errors but Pic freezes, can you tell me what is wrong please ?
Many thanks,
Re: Having problem to declare AN pins with 18F2620
Posted: 07 Jun 2010 00:17
by piort
hi,
try to make it in one call like
if the chip freeze again, post more code ....
hth a bit
btw i dont understand your hex config ...see DS39626E-page 224 datasheet of the 18f2620...
bit 7-6 Unimplemented: Read as ‘0’
bit 5 VCFG1: Voltage Reference Configuration bit (VREF- source)
1 = VREF- (AN2)
0 = VSS
bit 4 VCFG0: Voltage Reference Configuration bit (VREF+ source)
1 = VREF+ (AN3)
0 = VDD
bit 3-0 PCFG3:PCFG0: A/D Port Configuration Control bits:
1011 D D D D D D D D D A A A A // an0 to an3 analog
0x0E = 1110 and that is only an0 as analog ...
and the other cal with 0x82 = 0b10000010 ... the first 1 is not possible because read as 0 and the 4 lower bit config all analog channel .....
Re: Having problem to declare AN pins with 18F2620
Posted: 08 Jun 2010 15:07
by tihomir.losic
crocu wrote:It compiles with no errors but Pic freezes, can you tell me what is wrong please ?
Many thanks,
Hello,
In order to help you further please zip or rar your whole project folder,
and send it in attachment on our Support desk:
http://www.mikroe.com/esupport
it is important to send all the files in the project folder.
Thanks.
Best regards,
Losic Tihomir