PDA

View Full Version : Port A Issues



elec_mech
- 21st June 2005, 19:49
Hello, I'm having extremely bad luck with my "a" ports on my PIC 18F2525. I've included a snippet from a large program to help demostrate my program.

In effect, port a causes me nothing but trouble if I use for anything other than a simple on/off output. I understand it houses the A/D stuff and is consequently fickle to begin with. Thus, I've limited its use to turning on and off LEDs and powering a couple of switches (strictly output).

However, in my program I turn on one LED on porta.1 then immediately put power to a BCD switch on porta.4. As soon as porta.4 goes high, porta.1 goes low and turns off the LED! Here's a sample of code:

trisa = %00000000 'Set all port a's to outputs
porta = %00000000 'Set all ports on a to low
adcon1 = 7 'Make porta all digital I/O's
Main:

porta.1 = 1 'Light an LED

goto Switch_On

Switch_On:

porta.4 = 1 'porta.1 goes off for no apparent reason

'Do something

goto Main




And porta.1 goes off! Anyone have any ideas or suggestions?

BigWumpus
- 21st June 2005, 19:54
Please check:

Does PortA.4 require an Pull-Up-Resistance ?
Did you trap into a read-modify-write-problem, because to output of PortA.1 is bad designed and the voltage on this output can't rise to 3,x Volt or more. Then this input is read as "0" and written as "0" while changing PortA.4 !

www.sprut.de

elec_mech
- 21st June 2005, 21:07
Okay, silly me had been looking at all the posts for overcoming the A/D features on the "a" ports and nearly everywhere I went, the example programs used ADCON1 = 7. Since I have a PIC18F2525, I have several more A/D ports (?) and needed to set all of these as digital I/O, not analog. Thus, the fix is:

Adcon1 = $0F

BigWumpus, thank you for the guidance.

Hope this helps others!