Trouble with 16F628's PORTA


Closed Thread
Results 1 to 5 of 5
  1. #1
    SebastianO's Avatar
    SebastianO Guest

    Default Trouble with 16F628's PORTA

    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

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    as usual... datasheet>> analog comparator section >> CMCON register to disable them
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    SebastianO's Avatar
    SebastianO Guest


    Did you find this post helpful? Yes | No

    Default

    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?

  4. #4
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257


    Did you find this post helpful? Yes | No

    Question

    I don't quite follow your code, but anyways, have you set the TRISA register to all 1's?

    ie TRISA = 255

    J

  5. #5
    Join Date
    Nov 2005
    Posts
    14


    Did you find this post helpful? Yes | No

    Default PORTA prob as well... surprising solution

    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 ?

Similar Threads

  1. error worring pbp247
    By chai98a in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th January 2010, 05:51
  2. PortA digita input?
    By MOUNTAIN747 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th January 2009, 22:55
  3. PIC's ports individual bits manipulation - how to?
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 38
    Last Post: - 27th February 2007, 23:34
  4. 16f876 PortA set-up trouble?
    By ronjodu in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2006, 20:31
  5. Can anyone help a beginner in a struggle?
    By douglasjam in forum mel PIC BASIC
    Replies: 1
    Last Post: - 6th May 2005, 00:29

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts