Having problem to declare AN pins with 18F2620

General discussion on mikroC.
Post Reply
Author
Message
crocu
Posts: 71
Joined: 18 Jun 2008 09:28
Location: France, Macon

Having problem to declare AN pins with 18F2620

#1 Post by crocu » 06 Jun 2010 21:31

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,

piort
Posts: 1379
Joined: 28 Dec 2005 16:42
Location: Laval,Québec,Canada,Earth... :-)
Contact:

Re: Having problem to declare AN pins with 18F2620

#2 Post by piort » 07 Jun 2010 00:17

hi,
try to make it in one call like

Code: Select all

ADCON1 = 0b00001011; 
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 .....

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: Having problem to declare AN pins with 18F2620

#3 Post by tihomir.losic » 08 Jun 2010 15:07

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
mikroElektronika [Support team]

Post Reply

Return to “mikroC General”