I am doing a small code for PIC24FJ1024GB610 from Microchip, where I want to test PORTA

The code Below

#include <xc.h>

#pragma config FWDTEN = OFF
#pragma config FNOSC = FRC
#pragma config ICS = PGD2

unsigned int Pattern;

void Ports (void)
    TRISA = 0x0000;//all outputs
    ANSAbits.ANSA6 = 0;
    ANSAbits.ANSA7 = 0;
    ANSAbits.ANSA9 = 0;
    ANSAbits.ANSA10 = 0;//all digital ports

    LATA = Pattern;


int main (void)
    Pattern = 0xBBAA;

    Ports ();


    return 0;

What I expected to happen was:

  • Pattern is declared as an unsigned int
  • at main () Pattern = 0xBBAA
  • Program calls Ports ()
  • PORTA configured as Output TRISA = 0x0000
  • PORTA is configured as Digital ANSA = 0x0000
  • LATA = Pattern, if I debug the program, I would expect LATA = 0xBBAA in the SFR window.

When I debug the program, and open the SFR window, I get LATA = 0x82AA, as you can see in the screenshot below.

enter image description here

Helpful info:

Any help is appreciated.


1 Answer 1


You didn't supply a link to the datasheet, so I didn't look it up. My guess is that not all 16 bits of port A are implemented.

Port A pins also are sometimes used for the oscillator pins, the MCLR input, etc. Those aren't available as port A digital pins when those other roles are used.

You really need to read the datasheet.

  • \$\begingroup\$ PIC24FJ1024GA610/GB610 FAMILY - Indeed, not all pins of PortA exist physically. Out of all the ports on a PIC, PortA is typically the most "limited." What is connected to PortD, Adam? That seems to have all 16 pins. \$\endgroup\$
    – rdtsc
    Commented Aug 29, 2017 at 11:14
  • \$\begingroup\$ You guys were right, some pins are removed from the microcontroller. @Olin Lathrop I shall edit, and add a link to the datasheet. Thanks for the help \$\endgroup\$ Commented Aug 29, 2017 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.