• AVR Freaks

Hot![Solved] Can't use RA0/RA1 for digital I/O PIC16F630

Author
oxygène
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2020/06/21 02:16:17
  • Location: 0
  • Status: offline
2020/06/29 10:17:29 (permalink)
0

[Solved] Can't use RA0/RA1 for digital I/O PIC16F630

I though it might be because of the analog comparator, however I have no idea how to get around it.
Here's the configuration I tried:
 TRISA = 0b111111;
 TRISC = 0b111001;
 TRISCbits.RC1 = 0;
 WPUA = 0b110111;
 IOCA = 0b111111;
 INTCON = 0b10001110;
 PIE1 = 0;
 OPTION_REG = 0;
 CMCON = 0;
 VRCON = 0;

Can't enable WPUA on them either or IOCA (obviously), however they both work just fine on other pins.
What's worse is that PORTA always reads 101101, unless of course I save its value in a variable in which case it still gives zeros for those two bits.
post edited by oxygène - 2020/09/29 00:19:02

Don't be AVR: Easy to program, unstable in harshness.
Be PIC: Hard to figure out, resistant to noise.
#1

5 Replies Related Threads

    ric
    Super Member
    • Total Posts : 28660
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Can't use RA0/RA1 for digital I/O PIC16F630 2020/06/29 15:45:20 (permalink)
    +2 (2)
    "CMCON = 0" is not the correct way to turn off the comparators.
    The datasheet actually tells you the correct value in the "PORTA" chapter.
    http://ww1.microchip.com/...Doc/40039F.pdf#page=21
     
    Also note, even though the PIC16F630 lacks an ADC, which its sister device the PIC16F676 has, I have seen some reports that you still need to clear the ANSEL register (that supposedly doesn't exist on a PIC16F630).
    It couldn't hurt to do that too.
    That register is at address 0x91
     
     
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    RISC
    Super Member
    • Total Posts : 5778
    • Reward points : 0
    • Status: offline
    Re: Can't use RA0/RA1 for digital I/O PIC16F630 2020/06/29 16:10:19 (permalink)
    +1 (1)
    Hi Ric,
    Can you explain why CMCON = 0 is not correct to turn off comparators ?
    Regards

    For support make sure to check first here : http://microchipdeveloper.com
    There are hundreds of PIC, AVR, SAM...which one do YOU use ?
    #3
    ric
    Super Member
    • Total Posts : 28660
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Can't use RA0/RA1 for digital I/O PIC16F630 2020/06/29 16:26:56 (permalink)
    +1 (1)
    RISC
    Hi Ric,
    Can you explain why CMCON = 0 is not correct to turn off comparators ?
    Regards

    Just look in the comparators section in the datasheet.
    http://ww1.microchip.com/...Doc/40039F.pdf#page=41
    "CMCON = 0" sets the CM2:CM0 bits to "000"
    That is the top left option in that figure, which shows both the inputs are set to analog mode.
    You need the top right option, which is "111", so use "CMCON = 7"
    Strangely, the PORTA chapter used "5", which is wrong!
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    upand_at_them
    Super Member
    • Total Posts : 681
    • Reward points : 0
    • Joined: 2005/05/16 07:02:38
    • Location: Pennsylvania
    • Status: offline
    Re: Can't use RA0/RA1 for digital I/O PIC16F630 2020/06/29 16:29:22 (permalink)
    +1 (1)
    See the datasheet page 41!  In those older PICs CMCON = 0x07 is usually what turns off comparators.
     
    EDIT: ric beat me to it.
    #5
    oxygène
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2020/06/21 02:16:17
    • Location: 0
    • Status: offline
    Re: Can't use RA0/RA1 for digital I/O PIC16F630 2020/09/29 00:21:57 (permalink)
    0 (2)
    Thanks for the help and sorry for the delay I totally forgot to mark the thread as solved 👍👍👍

    Don't be AVR: Easy to program, unstable in harshness.
    Be PIC: Hard to figure out, resistant to noise.
    #6
    Jump to:
    © 2020 APG vNext Commercial Version 4.5