Can't make RA1 a digital Input on (10 out of 20) 16F887.


Closed Thread
Results 1 to 17 of 17
  1. #1
    Join Date
    Sep 2013
    Posts
    6

    Default Can't make RA1 a digital Input on (10 out of 20) 16F887.

    I thought I had my large code finalized, and now half of my boards have a problem.

    The RA1 input always reads 0. I have ANSEL = 0, ANSELH = 0, and have various settings of the other registers from the datasheet.
    I also tried using the alldigital.pbp include file.

    Below is a simplified test program (with the same problem) that flashes one of my existing LED's(RA0) and another LED(RE1) is controlled with a toggle switch input. I have a 10K pull up resistor on the switch input (RA1) to 5V, and I have measured the voltage on the chip pin. It changes state correctly with the switch, but the LED(RE1) stays on.

    If I use any port other then RA1, it works on all the PIC's.

    Also, all of the chips are running the code...cause the first LED flashes as it is supposed to.

    I feel that I am not getting something disabled correctly with the AD conv or the Comparators.
    This is my first time posting. I have spent hours with the datasheet. I usually find my answers by just reading others...but?

    Thanks,

    Paul


    #CONFIG
    __config _CONFIG1, _HS_OSC & _DEBUG_OFF & _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_ON & _PWRTE_ON & _WDT_OFF
    __config _CONFIG2, _WRT_OFF & _BOR40V
    #ENDCONFIG


    DEFINE OSC 20

    ANSEL = 0
    ANSELH = 0
    ADCON0 = 0
    ADCON1 = 0
    CM1CON0 = 0
    CM2CON0 = 0
    CM2CON1 = 0
    CCP1CON = 0
    CCP2CON = 0

    TRISA = %000000010
    TRISB = 0
    TRISC = 0
    TRISD = 0
    TRISE = 0


    Startup:
    LOW PORTA.0
    PAUSE 250
    HIGH PORTA.0
    PAUSE 250

    IF PORTA.1 = 0 THEN
    LOW PORTE.1
    ELSE
    HIGH PORTE.1
    ENDIF
    GOTO Startup

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: Can't make RA1 a digital Input on (10 out of 20) 16F887.

    Try this wild guess:

    IF PORTA.1 = 0 THEN
    PORTE.1 = 0
    ELSE
    PORTE.1 = 1
    ENDIF
    Robert


    EDIT: I also went through the datasheet and can't see any register you could have forgotten.
    Last edited by Demon; - 29th September 2013 at 00:58.

  3. #3
    Join Date
    Sep 2013
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: Can't make RA1 a digital Input on (10 out of 20) 16F887.

    Thanks for the reply.

    I gave that a try and still have the same results. I was originally using variable names for each pin, but removed them to simplify.

    I have done a lot of programming without problem. Can't believe I can't make an input work.
    In my larger program, I actually save this pin state to a USB flash drive. The input is always 0.
    The ANSEL = 0 and ANSELH = 0, is working for all the other pins they deals with.


    Paul

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: Can't make RA1 a digital Input on (10 out of 20) 16F887.

    Found it:

    TRISA = %000000010
    I count 9 digits.

    Robert

  5. #5
    Join Date
    Sep 2013
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: Can't make RA1 a digital Input on (10 out of 20) 16F887.

    Wow...

    I really thought that was gonna be it. Didn't notice that extra bit.

    But, it didn't seem to make them work...the other 10 all seem to be consistently working.
    Kinda wish I would have put the micro in a socket.


    What about VRCON? Is this a Read, Modify, Write issue?

    Paul

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: Can't make RA1 a digital Input on (10 out of 20) 16F887.

    I don't know the details of RMW. Hopefully someone else will have an idea 'cause this was all I had.

    Robert

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Can't make RA1 a digital Input on (10 out of 20) 16F887.

    Quote Originally Posted by paulgrut View Post
    I thought I had my large code finalized, and now half of my boards have a problem.

    The RA1 input always reads 0. I have ANSEL = 0, ANSELH = 0, and have various settings of the other registers from the datasheet.
    I also tried using the alldigital.pbp include file.

    So in summary, You have 20 pics all programmed alike, and only half work as expected?
    Perhaps you have gotten some sour hardware . . . perhaps?
    Can you toggle those pins with a simple code, apart from this program?
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  8. #8
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: Can't make RA1 a digital Input on (10 out of 20) 16F887.

    Hi,
    So, it's not only the PIC that differs on the ones that doesn't work, you are changing the whole board, including the PIC, correct?
    I think that since it works on some PICs (or boards rather, if that's the case) the code is likely not the fault. Had it been a faulty register setting it wouldn't have worked on any of them - but I've been wrong before....

    What's the supply voltage of the PIC (5V?) and what voltage levels are present at RA1 with the switch in either location?

    You say that you ground the pin to "make" the signal, is it possible that there are TWO (or more) grounds in your system and that they aren't connected. When you measure the voltage you reference the "correct" ground which, for whatever reason, isn't connected to PICs ground so it doesn't see the voltage that your DVM does?

    I'm pretty sure it's not RMW, especially so since your two outputs are on different ports. A Read Modify Write issue usually presents itself when you're trying to do several consecutive bit operations on a single port.

    I'm leaning towards a hardware issue of some sort though it IS strange that it works with "any other pin except RA1".... doesn't make sense but things usually doesn't untill you find the real reason.

    /Henrik.

  9. #9


    Did you find this post helpful? Yes | No

    Default Re: Can't make RA1 a digital Input on (10 out of 20) 16F887.

    The PIC's are "soldered in" on all the boards you have?

    All the boards are from the same batch?

    All the PIC's are from the same batch and silicon rev.?


    George
    Last edited by towlerg; - 29th September 2013 at 12:51.

  10. #10
    Join Date
    Sep 2013
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: Can't make RA1 a digital Input on (10 out of 20) 16F887.

    Yes. I have 20 boards with the PIC soldered in. And on half the RA1 input does not work.

    I am able to make the RA1 act as an output and it works correctly on all of them.

    I am seeing 2 different silicon date codes on the chips, but the problem is with some of each.

    The circuit boards are all from the same batch.

    The RA1 input is held high with 10K pullup resistor to 5V. The switch pulls this to ground. I have verified the voltage on the chip pin
    and it changes from 5V to 0V with the switch. I am going to look over all the ground traces and make sure there isn't (as Henrik asked)
    a seperated ground. Although the boards all look to be in good shape.

    Thanks for any other ideas. I might order some new 887's and see what happens. And some sockets also...

    Paul
    Last edited by paulgrut; - 29th September 2013 at 20:32.

  11. #11


    Did you find this post helpful? Yes | No

    Default Re: Can't make RA1 a digital Input on (10 out of 20) 16F887.

    I realize it's a pain to unsolder two PICs but the obvious thing to try is swapping the PIC from a working board to with the PIC from a non working board. Cold comfort but at least you will have a better idea if its the board or the PIC. Are the PICs DIP or SMD? If they're SMD try ChipQuik. BTW there is an errata for the 887, didn't see anthing obvious. George
    Last edited by towlerg; - 29th September 2013 at 22:24. Reason: old and stupid

  12. #12
    Join Date
    Sep 2013
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: Can't make RA1 a digital Input on (10 out of 20) 16F887.

    Update.

    All of the Ground traces are correct and tied together.

    But....After checking again. RA1 WILL NOT work as an output either.

    I will swap 2 of the chips. I agree, it is the next step. Not too bad...they are DIP.

    Paul
    Last edited by paulgrut; - 29th September 2013 at 22:33.

  13. #13
    Join Date
    Sep 2013
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: Can't make RA1 a digital Input on (10 out of 20) 16F887.

    Swapped the pic on a working board and a not working board....

    Problem stayed with the pic. Must be a pic problem.
    Just can't help but think I have something configured wrong in the code.
    What could cause a pic failure? These boards were built then tested bad. (no extended use) .

    Paul

  14. #14


    Did you find this post helpful? Yes | No

    Default Re: Can't make RA1 a digital Input on (10 out of 20) 16F887.

    have you verified the code in the working and non working PIC's?

  15. #15
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Can't make RA1 a digital Input on (10 out of 20) 16F887.

    Quote Originally Posted by paulgrut View Post
    What could cause a pic failure? These boards were built then tested bad. (no extended use) .

    Paul
    Static Electricity, short circuit, overload, bad programmer (device). What was the source of those PICs ? Microchip, Mouser, FleaBay ? Lots of Fake Chips out there, maybe you got unlucky that way . . . you gotta ask yourself, "What do electronics manufacturers do with parts that do not meet their high standards?". I would bet they wholesale them to somewhere in unmarked condition as scrap and they mysteriously get marked and marketed as "genuine". I am very dubious about off list suppliers.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  16. #16
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Can't make RA1 a digital Input on (10 out of 20) 16F887.

    Code:
    %000000010
    %00000010
    They are both the same number.

    Google RA1 Digital, and you can see the pain!

    if portA are all digital inputs, what value do you get reading portA into a byte?
    Code:
    byte = PORTA;
    What happens if you do this:
    Code:
    HIGH PORTA.0
    PAUSE 250
    LOW PORTA.0
    PAUSE 250
    So that portA isn't powering an LED while A1 is being read?
    Last edited by Art; - 11th October 2013 at 05:25.

  17. #17
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Can't make RA1 a digital Input on (10 out of 20) 16F887.

    This is your code tweaked for a PIC16F690, and it works:
    Code:
    #CONFIG
        __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BOR_OFF & _FCMEN_OFF & _IESO_OFF 
    ;__config _CONFIG2, _WRT_OFF & _BOR40V
    #ENDCONFIG
    
    
    DEFINE OSC 20
    
    ANSEL = 0
    ANSELH = 0
    ADCON0 = 0
    ADCON1 = 0
    CM1CON0 = 0
    CM2CON0 = 0
    CM2CON1 = 0
    CCP1CON = 0
    ;CCP2CON = 0
    portb=0
    portc=0
    porta=0
    TRISA = %00000010
    TRISB = 0
    TRISC = 0
    ;TRISD = 0
    ;TRISE = 0
    
    
    Startup:
    LOW PORTA.0
    PAUSE 250
    HIGH PORTA.0
    PAUSE 250
    
    IF PORTA.1 = 0 THEN
    LOW PORTc.1
    ELSE
    HIGH PORTc.1
    ENDIF
    GOTO Startup
    The registers a 690 does not have have been commented out. You will need a pull up on your input pin.
    Sorry I don't have an 887 to test upon.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. 16f887 portc input problems
    By lockjawz in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 31st March 2011, 14:02
  2. Replies: 2
    Last Post: - 1st May 2009, 08:23
  3. Really slow digital input
    By mbw123 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 30th March 2007, 04:06
  4. 18F4550 digital input
    By mbw123 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 29th March 2007, 02:43
  5. Replies: 2
    Last Post: - 5th June 2005, 19:55

Members who have read this thread : 0

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