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 ;
18F452 analog pins problem
Re: 18F452 analog pins problem
Hi,
If I understand correctly, you cannot use E0,A4 and A5 pins as analog ?
Regards,
Filip.
If I understand correctly, you cannot use E0,A4 and A5 pins as analog ?
Regards,
Filip.
Re: 18F452 analog pins problem
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.
Re: 18F452 analog pins problem
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
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
Re: 18F452 analog pins problem
Hi,
Can you try the earlier version of the compiler, just for testing purposes ?
Regards,
Filip.
Can you try the earlier version of the compiler, just for testing purposes ?
Regards,
Filip.
Re: 18F452 analog pins problem
This statement:
RA4 is always digital, never analogue
RA5 equates to AN4
Everything works perfectly for me using latest compiler version.
Working, tested example project attached
.. makes me wonder whether you are confusing PORT bit numbers with AN bit numbersother buttons that connect analog pins (E0,A4,A5) is not working.
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)
Re: 18F452 analog pins problem
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;
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
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;
hexreader wrote: ↑11 Aug 2022 10:16This statement:.. makes me wonder whether you are confusing PORT bit numbers with AN bit numbersother buttons that connect analog pins (E0,A4,A5) is not working.
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.
Re: 18F452 analog pins problem
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.
- Tanja_Kovacevic
- mikroElektronika team
- Posts: 98
- Joined: 09 Aug 2021 11:39
Re: 18F452 analog pins problem
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
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