Digital Input not working.

  • I have limit switches connected to i/o ports 5 and 6.
  • I have downloaded and verified they work using the online code.

But when I use the UserCode and log rc_dig_int5 and rc_dig_int6 in tihs code they never change even when the limit switches are toggled.

I am thinking there is something I need to setup in order to tell the controller that 5&6 need to be digital input?

MPLAB Right??

Are your limit switches in the I/O area (16 Ports, plus RX and TX) or in the Interrupt Area??

rc_dig_int5 and rc_dig_int6 are for the Interrupts, rc_dig_in05 and rc_dig_in06 are for the Digital Inputs, if so configured like in the code below.

Look in the ifi_aliases.h file for the descriptions of which Variables hold values from which Inputs…

========================================================
Does your “User_Initialization” function in the file “user_routines.c” look like this???

void User_Initialization (void)
{
/* FIRST: Set up the pins you want to use as analog INPUTs. */
  IO1 = IO2 = INPUT;        /* Used for analog inputs. */
    /* 
     Note: IO1 = IO2 = IO3 = IO4 = INPUT 
           is the same as the following:

           IO1 = INPUT;
           IO2 = INPUT;
           IO3 = INPUT;
           IO4 = INPUT;
    */

/* SECOND: Configure the number of analog channels. */
  Set_Number_of_Analog_Channels(TWO_ANALOG);     /* See ifi_aliases.h */

/* THIRD: Set up any extra digital inputs. */
  /* The six INTERRUPTS are already digital inputs. */
  /* If you need more then set them up here. */
  /* IOxx = IOyy = INPUT; */
  IO3 = IO4 = IO5 = IO6 = IO7 = IO8 = INPUT;        
  IO9 = IO10 = IO11 = IO12 = IO13 = IO15 = INPUT;        

/* FOURTH: Set up the pins you want to use as digital OUTPUTs. */
  IO14 = IO16 = OUTPUT;      

/* FIFTH: Initialize the values on the digital outputs. */
  rc_dig_out14 = rc_dig_out16 = 0; 

<< BIG SNIP >>