Welcome, Guest
Username: Password: Secret Key Remember me

TOPIC: How to specify specific pin(s) for analog and digital, mixed

Re: How to specify specific pin(s) for analog and digital, mixed 8 years 1 month ago #15855

  • RogerTango
  • RogerTango's Avatar
  • Offline
  • Fresh Boarder
  • Thanks received: 2
As the title says, I am working with some projects that utilize both analog, and digital and I think there are some conflicts in the coding.

I specify analog pin for ADin (Read ADC), but if I dont specify all_digital = true then my digital inputs dont work. Which, is a conflict in it's self.

I understand how pin(s) are made analog, Ive gone over the code at:
http://digital-diy.com/Proton-Basic-Cod ... n-adc.html
And used snippits with very good success reading voltage, and it works with this project too... reading a pot in 8 bit mode.

What I need to know how to do, and dont understand (I have examined the datasheet in depth but the clarity still eludes me) is how to set SPECIFIC pins to DIGITAL, thus eliminating the all_digital=true.

For example, this is what I have configed...


all_digital = true
DECLARE ADIN_RES 8
DECLARE ADIN_TAD FRC
DECLARE ADIN_STIME 50

TRISA = %00000011 ' Configure AN0 (PORTA.0+1) as an input
ADCON1 = %10000000 ' Set analogue input, Vref is Vdd






Page 46 of the proton manual details information about setting pins digital, but without enough insight for me to comprehend.

Please bear in mind I am a hobbyist and entirely self taught, thus I appreciate the help you guys offer when I have questions.

I do not want to post the full code because I am hopeful I can profit from this project (CW keyer for ham radio). Its not "top secret" but I wound want to provide an outsider access to a copy and paste solution nor have them profit from my labors.

(I would however be willing to share it if needed via e-mail to a MEMBER of the FORUM for examination)

Thanks much,
Andrew

Re: How to specify specific pin(s) for analog and digital, m 8 years 1 month ago #8694

  • RogerTango
  • RogerTango's Avatar
  • Offline
  • Fresh Boarder
  • Thanks received: 2
I should have mentioned, what keyed me in that "something" is wrong, the chip resets it's self when keying is being done, but I do NOT think it is in the coding (unless Proton chokes on a simple 2 level nested IF/THEN condition...) because this has been ported from my previous Picaxe code, which worked flawlessly there.

Andrew

Re: How to specify specific pin(s) for analog and digital, m 8 years 1 month ago #8703

  • RogerTango
  • RogerTango's Avatar
  • Offline
  • Fresh Boarder
  • Thanks received: 2
Upon reading in more depth "Interfacing PIC Microcontrollers" (ISBN-10: 0750680288), on startup port A (and port E if so equipped) are set to analog, and all other ports are set to digital.

Seeking verification that I understand that correctly.

If that is so, then all_digital=true is NOT needed for my project.

However if all_digital is not set, switches are not detected:
if portb.2 = 1 then
dosomething
end if

Andrew

Re: How to specify specific pin(s) for analog and digital, m 8 years 1 month ago #8704

  • RogerTango
  • RogerTango's Avatar
  • Offline
  • Fresh Boarder
  • Thanks received: 2
I did use TRIS to set specific pins to input and output, as they were so utilized.

Re: How to specify specific pin(s) for analog and digital, m 8 years 1 month ago #8707

  • jmessina
  • jmessina's Avatar
  • Offline
  • Senior Boarder
  • Posts: 44
  • Thanks received: 189
If you're talking about an 18F25K22, almost ALL the pins default to analog mode. Check out the ANSELA, ANSELB, and ANSELC registers in the datasheet.

Proton's 'All_Digital=true' may not fully support the 25K22 (but I don't know). The Amicus version has an issue with it from what I understand.

Be careful when reading any generic book about PIC's. While there's a lot about the devices that are similar, there's almost as much again that isn't. I always assume every new chip I look at is different, and that usually turns out to be worth the assumption.
The following user(s) said Thank You: RogerTango

Re: How to specify specific pin(s) for analog and digital, m 8 years 1 month ago #8715

  • RogerTango
  • RogerTango's Avatar
  • Offline
  • Fresh Boarder
  • Thanks received: 2
Yes, on target: 18F25K22... I didnt realize that. I will check the outlined registers on the datasheet and try to determine what the settings need to be.

Thank you for steering me in the right direction! Your help is much appreciated!

Andrew
Time to create page: 0.239 seconds