Skip to main content
3 of 4
added 120 characters in body
Majenko
  • 56.4k
  • 9
  • 106
  • 190

dsPIC33 and the upper half of PORTB

I am trying to use some of the IO pins of the dsPIC33FJ128GP802. The pins in question are RB8 thru RB11.

I have written a little program that reads the input value of one of those pins and outputs it to pin RA4.

All I get is straight 0, which ever of those pins I use.

If I use any PORTB pin from 7 down (i.e., the lower byte of the register), it functions perfectly.

I have scraped through the errata, and found nothing that has any bearing on this problem.

What am I missing?

Test program:

#include <p33Fxxxx.h>

_FWDT(FWDTEN_OFF)
_FOSCSEL(FNOSC_PRIPLL)
_FOSC(POSCMD_HS)

int main(void)
{
    unsigned int x=0;
    // Configure clock and PLL for 40 MIPS from 4MHz crystal
    CLKDIVbits.DOZE = 0;
    CLKDIVbits.DOZEN = 0;
    CLKDIVbits.FRCDIV = 0;
    CLKDIVbits.PLLPOST = 0;
    CLKDIVbits.PLLPRE = 0;
    PLLFBDbits.PLLDIV = 78;

    CMCONbits.C1OUTEN=0;
    CMCONbits.C2OUTEN=0;

    // Disable all ADC pins (make them digital)
    AD1PCFGL = 0xFFFF;

    // Configure IO pins
    TRISB=0xFFFF;           // All PORTB Input
    TRISAbits.TRISA4=0;     // RA4 Output

    while(1)
    {
        // Send input state to output pin
        LATAbits.LATA4 = PORTBbits.RB10;
    }
}

Other useful info:

Microchip Language Tool Shell Version v3_30 (Build date: Jun 21 2011).

The inputs are being driven by an Arduino, but using that, or hard-wiring to \$V_{LH}\$ or \$V_{LL}\$ makes no difference.

Majenko
  • 56.4k
  • 9
  • 106
  • 190