• AVR Freaks

Hot!I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454

Author
vra
Senior Member
  • Total Posts : 142
  • Reward points : 0
  • Joined: 2014/07/14 18:35:19
  • Location: 0
  • Status: offline
2020/05/25 16:59:17 (permalink)
0

I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454

Hi all, how are you? I'm doing some applications with a PIC16F1454 where I've the pins RC4 and RC5 as outputs; RC1, RC2 and RC3 as inputs for some button activations. The pin that is isn't working as expected is RC1 because it isn't answering to button activations.
 
I readed the datasheet and it says that this pin (RC1) is multiplexed with other functions as outputs priorities like follows:
 
RC1       ICSPCLK
             SDA(4)
             SDI(4)
             RC1
 
and of course the priority is for ICSPCLK, now, that function must be controlled for the programmer automatically (I don't need to set de DEBUG bit of CONFIG2) then so I think the priority now is SDA/SDI, what I need to know here i how to I change the priorities to make the RC1 work as GPIO and not as another peripheral, I've searched all the datasheet (I think) and I found nothing about how to set that specific function as default.
 
This are my PORTC config functions:
 

void PortC_Conf(void) /* Function to configure the port C pins. */
{
    ANSELC = 0x00; /* All analog inputs disabled. */
    TRISC = 0x0e; /* Port C pins RC1, RC2 and RC3 as inputs,
                                     * the rest as outputs. */
}

 
and this is the simple test functions that I've making:
 

while(1)
{
if(PORTCbits.RC1 || PORTCbits.RC2 || PORTCbits.RC3)
{
PORTCbits.RC4 = 1;
PORTCbits.RC5 = 1;
}
else
{
PORTCbits.RC4 = 0;
PORTCbits.RC5 = 0;
}

 
in the piece of code above the if condition works with all but nothing happens when RC1 is at logic "1". I know that I can do this with input change notification in port A but since that port has ICSP pins to then I think I gonna have the same problem with those pins son thats why I' testing this in first place.
 
Can you help me with this? Thanks in advance for the help.
#1

19 Replies Related Threads

    ric
    Super Member
    • Total Posts : 27635
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/25 17:09:56 (permalink)
    0
    Can you confirm the chip is NOT in debug mode when you do this test?
    i.e. you must just program the chip in normal "production" mode.

    Change
     PORTCbits.RC4 = 1;
     PORTCbits.RC5 = 1;
    to
     LATCbits.LATC4 = 1;
     LATCbits.LATC5 = 1;
     
    always follow the rule, "read from PORT, write to LAT."

    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
    ric
    Super Member
    • Total Posts : 27635
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/25 17:26:57 (permalink)
    +1 (1)
    Valery
    I readed the datasheet and it says that this pin (RC1) is multiplexed with other functions as outputs priorities like follows:

    Note, as you stated, that is a table of output priorities. Nothing to do with input.
     
    Only two things can stop you reading RC1
    #1 The chip is in debug mode, so that pin is dedicated to the debugger
    #2 The pin is in analog mode (if ANSEL hasn't been set correctly.
     
    The pin can still be read as an input even when some internal peripheral is set to drive it as an output.
     

    and of course the priority is for ICSPCLK, now, that function must be controlled for the programmer automatically (I don't need to set de DEBUG bit of CONFIG2) then so I think the priority now is SDA/SDI

    It is hard to make out what you are really saying here.
    As you say, you can't control the DEBUG biut yourself, it is controlled by the programmer.
    Are you simply sayin you are not using the debugger?
     
    Please post the ENTIRE program, not just snippets.
     

    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!
    #3
    upand_at_them
    Super Member
    • Total Posts : 532
    • Reward points : 0
    • Joined: 2005/05/16 07:02:38
    • Location: Pennsylvania
    • Status: online
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/25 17:27:05 (permalink)
    0
    Do you have a programmer attached?  It may not be releasing that pin.  For code, you only need to clear ANSELC, which you've done, because the MSSP module is turned off by default.
     
    #4
    vra
    Senior Member
    • Total Posts : 142
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/26 02:28:12 (permalink)
    0
    I forgot to to tel that I'm simulating it in proteus, not programming to the real device. The entire code is
     
    the main function:
     
     

    #include <xc.h>
    #include "sistema.h"
    #include "E_S.h"
    void main (void)
    {
    Clock_Conf(); /* First are configured the system clocks.*/
    PortC_Conf(); /* Configuration of port used as I/O. */

    while(1)
    {
    if(PORTCbits.RC1 || PORTCbits.RC2 || PORTCbits.RC3)
    {
    LATCbits.LATC4 = 1;
    LATCbits.LATC5 = 1;
    }
    else
    {
    LATCbits.LATC4 = 0;
    LATCbits.LATC5 = 0;

    }
    }
    return;
    }

     
    The the configuration libs for the port:
     
    E_S.h
     

    #ifndef XC_E_S_H
    #define XC_E_S_H
    #include <xc.h>
    void PortC_Conf(void); /* Function prototype to configure the port
    * C pins. */
    #endif /* XC_E_S_H */

     
    E_S.c
     

    #include <xc.h>
    #include "E_S.h"
    void PortC_Conf(void) /* Function to configure the port C pins. */
    {
    ANSELC = 0x00; /* All analog inputs disabled. */
    TRISC = 0x0e; /* Port C pins RC1, RC2 and RC3 as inputs,
    * the rest as outputs. */
    }

     
    the clock configurarion libs:
     
    sistema.h:
     

    #ifndef XC_SISTEMA_H
    #define XC_SISTEMA_H
    #include <xc.h>
    /*********Definition of configuration parameters to the internal clock*********/
    #define INT16M 1111
    #define INT8M 1110
    #define INT4M 1101
    #define INT2M 1100
    #define INT1M 1011
    #define INT500d 1010
    #define INT250d 1001
    #define INT125d 1000
    #define INT500de 0111/*By default at reset*/.
    #define INT250k 0110
    #define INT125k 0101
    #define INT625k 0100
    #define INT3125k 0010
    #define INT31klf 0000/*Low frequency watch.*/

    void Clock_Conf(void); /* Function prototype to configure the
    * system clocks. */
    #endif /* XC_SISTEMA_H */

     
    sistema.c:
     

    #include <xc.h>
    #include "sistema.h"
    void Clock_Conf() /* Function to configure the system */
    { /* system watches. */
    OSCCONbits.IRCF = INT31klf; /* Internal clock configured to 31KHz. */
    T1CONbits.T1OSCEN = 0x01; /* Secondary oscillator enabled to use a
    * 32768 Hz crystal in order to keep time
    * between chimes activation. */
    }

    and the configuration bits file:
     

    #include <xc.h>
    // PIC16F1454 Configuration Bit Settings
    // 'C' source line config statements
    // CONFIG1
    #pragma config FOSC = INTOSC // Oscillator Selection Bits (INTOSC oscillator: I/O function on CLKIN pin)
    #pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
    #pragma config PWRTE = OFF // Power-up Timer Enable (PWRT disabled)
    #pragma config MCLRE = ON // MCLR Pin Function Select (MCLR/VPP pin function is MCLR)
    #pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
    #pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled)
    #pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
    #pragma config IESO = ON // Internal/External Switchover Mode (Internal/External Switchover Mode is enabled)
    #pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is enabled)
    // CONFIG2
    #pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)
    #pragma config CPUDIV = CLKDIV6 // CPU System Clock Selection Bit (CPU system clock divided by 6)
    #pragma config USBLSCLK = 48MHz // USB Low SPeed Clock Selection bit (System clock expects 48 MHz, FS/LS USB CLKENs divide-by is set to 8.)
    #pragma config PLLMULT = 3x // PLL Multipler Selection Bit (3x Output Frequency Selected)
    #pragma config PLLEN = DISABLED // PLL Enable Bit (3x or 4x PLL Disabled)
    #pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
    #pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
    #pragma config LPBOR = OFF // Low-Power Brown Out Reset (Low-Power BOR is disabled)
    #pragma config LVP = OFF // Low-Voltage Programming Enable (Low-voltage programming enabled)
    // #pragma config statements should precede project file includes.
    // Use project enums instead of #define for ON and OFF.

     
    As yo can see in E_S.c the ANSEL register is set to "0" to disable all the analog functions.
     
     
    NOTE: what I tried to say in this:
     
    "and of course the priority is for ICSPCLK, now, that function must be controlled for the programmer automatically (I don't need to set de DEBUG bit of CONFIG2) then so I think the priority now is SDA/SDI"
     
    is that I think the last priority to the RC1 pin is to act like a GPIO so in that case all the other functions will have priority over that, so I'm asking how to change that priority because right now I think the priority explanation like the interrupt priority on 16 bit PICs.
    #5
    vra
    Senior Member
    • Total Posts : 142
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/26 02:31:22 (permalink)
    0
    Ho can I config that the chip is or not in debug mode?
    #6
    ric
    Super Member
    • Total Posts : 27635
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/26 02:44:19 (permalink)
    +2 (2)
    Valery
    I forgot to to tel that I'm simulating it in proteus, not programming to the real device.

    You should have. This is almost certainly a bug in Proteus then.
    Try it on real hardware.
     

    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!
    #7
    RISC
    Super Member
    • Total Posts : 5753
    • Reward points : 0
    • Status: offline
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/26 06:07:49 (permalink)
    0
    Hi,
    There is an evaluation board for PIC16F1454 (if you want to use USB)
    Are you planning to use the USB on this device ?
    Regards
     
    #8
    vra
    Senior Member
    • Total Posts : 142
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/26 06:57:35 (permalink)
    0
    RISC
    Hi,
    There is an evaluation board for PIC16F1454 (if you want to use USB)
    Are you planning to use the USB on this device ?
    Regards
     




    Not right now but thanks for the advice.
    #9
    vra
    Senior Member
    • Total Posts : 142
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/26 06:58:45 (permalink)
    +1 (1)
    ric
    Valery
    I forgot to to tel that I'm simulating it in proteus, not programming to the real device.

    You should have. This is almost certainly a bug in Proteus then.
    Try it on real hardware.
     


    Thanks Ric but right now the requirement is only for simulation, nayway i'll try othe way.
    #10
    RISC
    Super Member
    • Total Posts : 5753
    • Reward points : 0
    • Status: offline
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/26 07:40:37 (permalink)
    +2 (2)
    hi,
    Just to reinforce previous messages...don't spend too much time with Proteus if you plan to use real hardware later as you'll have to retest and redo some software adjustments...remember that Proteus does not take into account silicon limitations of the real silicon (errata...).
    Regards
    #11
    vra
    Senior Member
    • Total Posts : 142
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/27 19:04:07 (permalink)
    0
    RISC
    hi,
    Just to reinforce previous messages...don't spend too much time with Proteus if you plan to use real hardware later as you'll have to retest and redo some software adjustments...remember that Proteus does not take into account silicon limitations of the real silicon (errata...).
    Regards


    Thanks for the advice
    #12
    vra
    Senior Member
    • Total Posts : 142
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/28 11:45:40 (permalink)
    0
    Just to clarify, I know is a lot better to work with the real hardware but I dont have the real hardware and in my country several bussines are closed due COVID-19, between the closed bussiness are the shipping companies so in order to not waste all the time I use simulation.
    post edited by vra - 2020/05/28 11:46:59
    #13
    ric
    Super Member
    • Total Posts : 27635
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/28 13:00:32 (permalink)
    +1 (1)
    The simulator bug is probbaly just with that device.
    As it's a simulator, it's easy for you to just change to a different (but similar) PIC to proceed.
     

    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!
    #14
    vra
    Senior Member
    • Total Posts : 142
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/28 18:29:02 (permalink)
    0
    ric
    The simulator bug is probbaly just with that device.
    As it's a simulator, it's easy for you to just change to a different (but similar) PIC to proceed.
     


    I've changed to a PIC16F1503 and at least until now it has the same behavior on that pin, or the bug is in the model of that series of PIC in the simulator or I need to read a little bit more.
    #15
    vra
    Senior Member
    • Total Posts : 142
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/28 18:29:05 (permalink)
    0
    ric
    The simulator bug is probbaly just with that device.
    As it's a simulator, it's easy for you to just change to a different (but similar) PIC to proceed.
     


    I've changed to a PIC16F1503 and at least until now it has the same behavior on that pin, or the bug is in the model of that series of PIC in the simulator or I need to read a little bit more.
    #16
    ric
    Super Member
    • Total Posts : 27635
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/28 18:30:34 (permalink)
    +2 (2)
    You could ask the people who make Proteus. It is not a Microchip product.
     

    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!
    #17
    vra
    Senior Member
    • Total Posts : 142
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/28 18:44:48 (permalink)
    0
    Yes thank you
    #18
    RISC
    Super Member
    • Total Posts : 5753
    • Reward points : 0
    • Status: offline
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/29 06:56:09 (permalink)
    0
    Hi,
    For PIC16F1503, can you check that the C1ON bit in CM1CON0 and C2ON bit in CM2CON0 are set to 0 ?
    Regards
    #19
    vra
    Senior Member
    • Total Posts : 142
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: I can't use the RC1 pin as a general purpose Input pin with the PIC16F1454 2020/05/30 05:44:33 (permalink)
    0
    RISC
    Hi,
    For PIC16F1503, can you check that the C1ON bit in CM1CON0 and C2ON bit in CM2CON0 are set to 0 ?
    Regards




    Yep, I've checked that all peripherals associated with that pin are disabled. In addition I configured the RCbits 0 and 1 as outputs through thre TRIS bits then I noted that the LAT associated bit is set but the RC bit doesn't.
    #20
    Jump to:
    © 2020 APG vNext Commercial Version 4.5