16F628 PortA pin connections - wierd


Closed Thread
Results 1 to 6 of 6
  1. #1
    john meiers's Avatar
    john meiers Guest

    Default 16F628 PortA pin connections - wierd

    I can't figure this out - if I pull a PORTA pin low via a 10k and have the program look for a button push (+5v), everything works fine. However, if I try to pull it high with the 10k and have the program look for a button push thats 0v, it will not work. Strangely enough, though, if the pin is hooked directly to 5v (not through a resistor) and a 0v pulse is applied THROUGH a 10k resistor to the pin, it reads it. Is there a way to correct this? I've tried using a PORTA_pullup in the program but evidently you can't do that with this chip?

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    PortA works just fine providing you disable the Comparators FIRST!!!! They share PortA and are switched-in by default on Power-up as you discovered when you read the DATASHEET for that PIC.

    CMCON=7

    Put that somewhere at the top of your code where you initialise the PIC Ports for Input with your TRIS statement (you are using TRISA and TRISB aren't you?) and all will be well.

    PortA doesn't have internal pull-up's, an external 10K will be just fine.

    Gee, I wish I got $1 for every time disabling Comparators, ADC's and reading the Datasheet came up in conversation...

  3. #3
    john meiers's Avatar
    john meiers Guest


    Did you find this post helpful? Yes | No

    Default

    Doesn't the ALL_DIGITAL = TRUE command take care of that? I even tried replacing that with CMCON command, but still no worky. With the PORTA.0 pin tied high through the 10k, I still read practically 0v on the pin with the VMM. Here is the code preface:

    Device = 16F628A
    XTAL = 4

    ALL_DIGITAL = TRUE
    PORTB_PULLUPS = On
    TRISB = 0

    Symbol SW1 = PORTA.0
    Symbol LED1 = PORTB.0
    Symbol LED2 = PORTB.1

    Dim CounterA As Byte

    TRISA = $F0
    PORTB = 0

    Any ideas?

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Any ideas?
    Yes, you're on the wrong forum. This one is for compilers that work...

    But if your pin is showing 0v... it looks like the pin is switched to OUTPUT and not INPUT. TRIS statements take care of that in the MeLabs compilers... but from your code it doesn't look like you've one of those.

    Oh... looking again... your TRISA=$F0 has PortA.0 as an OUTPUT.

  5. #5
    john meiers's Avatar
    john meiers Guest


    Did you find this post helpful? Yes | No

    Default

    ouch..having a bad day? I'm using the Proton IDE Lite compiler...it works great and its free. But fixing that TRIS statement did the trick, so thank you for your help!

  6. #6
    Join Date
    Nov 2008
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: 16F628 PortA pin connections - wierd

    Quote Originally Posted by Melanie View Post
    ......Gee, I wish I got $1 for every time disabling Comparators, ADC's and reading the Datasheet came up in conversation...
    I think, you would be a millionaire!
    I read a lot in this forum and I find very much smart answers, especially yours.
    Thanks!

Similar Threads

  1. My code for TV remote and MIBAM for RGB control
    By idtat in forum Code Examples
    Replies: 4
    Last Post: - 12th January 2013, 20:52
  2. Is this a K Type sensor?
    By jessey in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 21st November 2009, 13:55
  3. DS1820 with 16f688
    By jessey in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 23rd May 2009, 05:07
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17:07

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