title: How to configure correctly a PIC18 port D for output direction?
body: <p>I'm developing a firmware to control a PIC18F45k80 pinout on a customized board. 
  Before loading and programming this pic with the final version I was testing my program/debug environment (MPLABX IDE + Pickit3) with the simplest user code: toggle some portD outputs with a 50 ms period. </p>
  
  <p>3 pins of them works propperly (RD6, RD5, RD4) but it's not the case of RD3 and R2. They have no signal, they never turn on. The pin stills with 0 all the execution time. All the pins are configured and activated with the same way at the same time, as you can see in the next code:</p>
  
  <p>main.c file:</p>
  
  <pre><code>//C libraries
  #include &lt;stdio.h&gt;
  #include &lt;stdint.h&gt;
  #include &lt;stdbool.h&gt;
  
  #include &lt;pic18f45k80.h&gt;
  #include "18f45k80_mainconfig.h"
  #include &lt;xc.h&gt;
  
   //Application dependent libraries
   #include "gold_whyl_task.h"
  
   /*outputs defines*/
   #define CADENZA     PORTDbits.RD2 //problem with this bit
   #define CAPW        PORTDbits.RD3 //problem with this bit
   #define FREQFISSA   PORTDbits.RD4
   #define FISSAWAIL   PORTDbits.RD5
   #define COMCICLOSIR PORTDbits.RD6
  
   /*inputs - debug*/
   #define PGC         PORTBbits.RB6
   #define PGD         PORTBbits.RB7
  
   int main() 
    {
  
      TRISDbits.TRISD0=1;//input ACTIVACIOn 
      TRISDbits.TRISD1=1;//input CLACSON  
      TRISBbits.TRISB6=1;//pdg
      TRISBbits.TRISB7=1;//pdc
  
      /*outputs*/   
      TRISDbits.TRISD2=0;//output CADENZA //problem with this
      TRISDbits.TRISD3=0;//output CAPW  //problem with this
  
      TRISDbits.TRISD4=0;//output FREQFIJA   
      TRISDbits.TRISD5=0;//output FIJAWAIL 
      TRISDbits.TRISD6=0;//output COMCICLOSIR   
  
      while(1)
        { 
              COMCICLOSIR=0;
              FISSAWAIL=0;
              CAPW=0;
              CADENZA=0;
              FREQFISSA=0;
  
              __delay_ms(50);
              COMCICLOSIR=1;
              FISSAWAIL=1;
              CAPW=1; //this assignment has no effect --&gt; it stills 0
              CADENZA=1;//this assignment has no effect--&gt; it stills 0     
              FREQFISSA=1;
              __delay_ms(50);
        }
   }
  </code></pre>
  
  <p>What can be happening? 
  Is there something wrong with defines, port configuration, etc? </p>