PIC16F887 PORTA problem

Quote from wolleDD on September 2, 2025, 11:58 amHi together,
I tried to use a PIC16F887 PORTA as output. I set all needed configurations (in my opinion), such as:
FOSC in CONFIG1 as INTOSCIO (RA6/RA7 for IO),
OSCCON = 0b01110101; // OSC settings
ADCON0bits.ADON = 0; // ADC off
ADCON1 = 0x00; // Vref internal
ANSEL = 0x00; // PORTA analog off
ANSELH = 0x00; // PORTB/E analog off
CM1CON0bits.C1ON = 0; // Comperator 1 off
CM2CON0bits.C2ON = 0; // Comperator 2 offand at last TRISA = 0x00; // PortA for output
But if I set PORTA = 0xFF, only bits 0..5 are set.
Can help anyone to find my mistake? Thank you very much!
Hi together,
I tried to use a PIC16F887 PORTA as output. I set all needed configurations (in my opinion), such as:
FOSC in CONFIG1 as INTOSCIO (RA6/RA7 for IO),
OSCCON = 0b01110101; // OSC settings
ADCON0bits.ADON = 0; // ADC off
ADCON1 = 0x00; // Vref internal
ANSEL = 0x00; // PORTA analog off
ANSELH = 0x00; // PORTB/E analog off
CM1CON0bits.C1ON = 0; // Comperator 1 off
CM2CON0bits.C2ON = 0; // Comperator 2 off
and at last TRISA = 0x00; // PortA for output
But if I set PORTA = 0xFF, only bits 0..5 are set.
Can help anyone to find my mistake? Thank you very much!

Quote from arcachofo on September 7, 2025, 2:07 pmHi, thanks for reporting.
I'm not at my computer now, so I'm very limited, but if you share your hex file I can try to find what is happening.
Hi, thanks for reporting.
I'm not at my computer now, so I'm very limited, but if you share your hex file I can try to find what is happening.

Quote from wolleDD on September 11, 2025, 9:11 amHello arachofo,
sorry for my late replay. I send you attached a zip file with the hex file, the C source and the sim file.
The example here is only toggling PORTA, but RA6 and RA7 doesn’t work.
Thank you very much!
Best regards
Hello arachofo,
sorry for my late replay. I send you attached a zip file with the hex file, the C source and the sim file.
The example here is only toggling PORTA, but RA6 and RA7 doesn’t work.
Thank you very much!
Best regards
Uploaded files:
Quote from arcachofo on September 15, 2025, 10:29 amThanks for the files, but seems that the hex file does not match the source code, PORTA is doing nothing.
Thanks for the files, but seems that the hex file does not match the source code, PORTA is doing nothing.