18F452 analog pins problem

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
MedBoy
Posts: 137
Joined: 11 Jul 2012 11:45

18F452 analog pins problem

#1 Post by MedBoy » 04 Aug 2022 12:01

Hi everyone. I use 18F452, 7 buttons and 2 Analog input(A0,A1). Some button connections to analog pins that E0,A4 and A5. I made input that pins via Trisa and Trisc registers. and i made digital that pins via ADCON1 register. Normal buttons that is not analog pins (C6,C5..) is work correctly. But other buttons that connect analog pins (E0,A4,A5) is not working. I can not solve. Should i use another register for define pins to digital? Please help me.

ADCON1 = 0b10000100 ;

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: 18F452 analog pins problem

#2 Post by filip » 04 Aug 2022 14:08

Hi,

If I understand correctly, you cannot use E0,A4 and A5 pins as analog ?

Regards,
Filip.

MedBoy
Posts: 137
Joined: 11 Jul 2012 11:45

Re: 18F452 analog pins problem

#3 Post by MedBoy » 04 Aug 2022 21:13

No. Exact opposite. I can not use as digital input E0, A4 and A5. That pins are working analog mode. I want to use digital input for buttons. I am using just ADCON1 register for digital function. I think ADCON1 is not enough or i could not use correctly that register.
filip wrote:
04 Aug 2022 14:08
Hi,

If I understand correctly, you cannot use E0,A4 and A5 pins as analog ?

Regards,
Filip.

MedBoy
Posts: 137
Joined: 11 Jul 2012 11:45

Re: 18F452 analog pins problem

#4 Post by MedBoy » 09 Aug 2022 19:01

I think my problem is same with below link issue. According to the link I shared, ADCON1 register works in version 6.6.3. But i think ADCON1 register code does not work my latest 7.6.0 version.
According to my design, E0, A4 and A5 pins are pull-up normally, that pins goes to low level when press button. I can not change pins pull-up mode like your suggest that below link. because my pcbs and membran panels produced :( . please help about how i can solve my problem.

viewtopic.php?f=88&t=73538&p=294900&hil ... 52#p294900
filip wrote:
04 Aug 2022 14:08
Hi,

If I understand correctly, you cannot use E0,A4 and A5 pins as analog ?

Regards,
Filip.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: 18F452 analog pins problem

#5 Post by filip » 11 Aug 2022 08:21

Hi,

Can you try the earlier version of the compiler, just for testing purposes ?

Regards,
Filip.

MedBoy
Posts: 137
Joined: 11 Jul 2012 11:45

Re: 18F452 analog pins problem

#6 Post by MedBoy » 11 Aug 2022 10:03

I dont know how i can download earlier version. can you share version 6.6.3 link?
filip wrote:
11 Aug 2022 08:21
Hi,

Can you try the earlier version of the compiler, just for testing purposes ?

Regards,
Filip.

hexreader
Posts: 1785
Joined: 27 Jun 2010 12:07
Location: England

Re: 18F452 analog pins problem

#7 Post by hexreader » 11 Aug 2022 10:16

This statement:
other buttons that connect analog pins (E0,A4,A5) is not working.
.. makes me wonder whether you are confusing PORT bit numbers with AN bit numbers

RA4 is always digital, never analogue
RA5 equates to AN4

Everything works perfectly for me using latest compiler version.
Working, tested example project attached
Attachments
Forum.zip
(15.29 KiB) Downloaded 34 times
Start every day with a smile...... (get it over with) :)

MedBoy
Posts: 137
Joined: 11 Jul 2012 11:45

Re: 18F452 analog pins problem

#8 Post by MedBoy » 11 Aug 2022 10:39

Hi Hexreader. Thanks for your reply. I try your ADCON0 and ADCON1 register settings but my problem continues. I am using that analog pins as button input, not output like in your code. I can write to High or Low analog pin when it be output. I can not use as button input. That pins behave logic level Low even though logic level pull-up.
My register settings in below;

Code: Select all

ADCON0 = 0x81;                        // AD on, Fosc/64
ADCON1 = 0xc4;                        // Fosc/64, AN0, AN1, AN3 analogue - rest digital

TRISA=0b110011;
TRISB=0b00000000;
TRISC=0b01101001;
TRISD=0b00000000;
TRISE=0b101;
I am a senior programmer and I have never worked before with 18F452, this is my first experince. I know this is so easy in programming. But i can not do that, so I'm about to pull my hair out of anger :cry:




hexreader wrote:
11 Aug 2022 10:16
This statement:
other buttons that connect analog pins (E0,A4,A5) is not working.
.. makes me wonder whether you are confusing PORT bit numbers with AN bit numbers

RA4 is always digital, never analogue
RA5 equates to AN4

Everything works perfectly for me using latest compiler version.
Working, tested example project attached
Last edited by MedBoy on 11 Aug 2022 12:24, edited 4 times in total.

MedBoy
Posts: 137
Joined: 11 Jul 2012 11:45

Re: 18F452 analog pins problem

#9 Post by MedBoy » 11 Aug 2022 10:44

..

MedBoy
Posts: 137
Joined: 11 Jul 2012 11:45

Re: 18F452 analog pins problem

#10 Post by MedBoy » 15 Aug 2022 22:54

Mikroelektronika team has been leaving my questions unanswered for almost 2 years. My last 3-4 questions to the forum were left unanswered. I think it's time to stop using mikroelektronika compilers and their products.
filip wrote:
11 Aug 2022 08:21
Hi,

Can you try the earlier version of the compiler, just for testing purposes ?

Regards,
Filip.

User avatar
Tanja_Kovacevic
mikroElektronika team
Posts: 98
Joined: 09 Aug 2021 11:39

Re: 18F452 analog pins problem

#11 Post by Tanja_Kovacevic » 29 Aug 2022 13:03

Hi MedBoy,

Can you please tell us what version of mikroC PRO for PIC you need?
In the location where the compiler is installed, you can find the file named "whatsnew.txt".
It can help you to determine what exactly you need,
or if you have an old project just find out on which version it was developed.

I apologize if you did not get answers to all your questions.
My advice is to prefer tickets from our website or to send us an email to support [at] mikroe [dot] com.


Kind regards,
Tanja

Post Reply

Return to “mikroC PRO for PIC General”