PDA

View Full Version : Trouble with 16F628's PORTA



SebastianO
- 31st October 2005, 06:53
Hello,
I am facing a really annoying problem. The PORTA of my 16F628 doest not want to cooperate with me as input. The biggest ptoblem is that only the RA0 pin can be used as input, the rest of the pins: RA1, RA2 and RA3 does not react to any inputs. I have set the cmcon register to 0x07, but nothing, nothing.....
If anybody has any idea about what is hapenning, please don't hasitate to complete this topic.
Thank you in advabce your responses.

As development tool I use MPlab IDE. A short fragment of my code:

if((PORTA & 0x01) == TRUE)
{
PORTB = 0x01;
}
else
if((PORTA & 0x02) == TRUE)
{
PORTB = 0x02;
}
else
if((PORTA & 0x04) == TRUE)
{
PORTB = 0x04;
}
else
if((PORTA & 0x08) == TRUE)
{PORTB = 0x08;
}

where TRUE is defined as 0x01

mister_e
- 31st October 2005, 07:11
as usual... datasheet>> analog comparator section >> CMCON register to disable them

SebastianO
- 31st October 2005, 07:14
I already mentioned in my topic that I have disabled the comparators from the PORTA pins. CMCON = oxo7 isalready set by me.
Any other sugestions?

Squibcakes
- 2nd November 2005, 23:13
I don't quite follow your code, but anyways, have you set the TRISA register to all 1's?

ie TRISA = 255

J

Muzza
- 4th November 2005, 13:47
I developed a pulse reader application on a 16F84A.. worked well.
Needed the Timer1 function and compiled the code to a 16F628.
Setup the ports as follows:-
'Setup the hardware, define i/p and o/p
define osc 4
CMCON = 7 'turn comparators off
VRCON = 0
TRISB = 0 'set all PortB pins to outputs
TRISA = %00000111 'set RA0, RA1 & RA2 to input, all other outputs
I was using PortA1 for i/p and PortB4 for o/p on the 'F84A and after adding the CMCON and VRCON plugged in a 'F628 in lieu of the 'F84A.

Didn't work !!

Eventually, I found that if I reversed the i/p and o/p ports i.e PortA1 for o/p and PortB4 for i/p it worked.
TRISB = 1
TRISA = 0

My theory is that it is the Schmitt trigger on A0-A5 is causing the issue. Don't see how, as yet, as the i/p is a clean squarewave from a signal generator (am testing on the bench at the moment).

May give you a clue... and maybe someone has more info on this ?