I've been having a very strange problem with my PIC16F15345 microcontrollers. I'm trying to read a digital input state from a specific pin on the microcontroller (Pin2, or RA5). My setup code is below:
#include <xc.h>
#include <pic.h>
#include <pic16F15345.h>
#define _XTAL_FREQ 32000000
#pragma config WDTE = OFF
void main(void){
OSCFRQbits.HFFRQ = 0b110; //set HFINTOSC to 32MHz
OSCCON1bits.NOSC = 0b110; //set clock to HFINTOSC
TRISA = 0b11111111; //set all portA bits to input
ANSELA = 0b00000000; //set all portA bits to digital input
while(1)
{
//loop forever;
}
return;
}
I'm using the latest XC8 compiler, MPLABx IDE, and a PICKIT3 programmer. I'm using an arduino's output pins to toggle the state of the input pin on the PIC, so I don't have to worry about debouncing and can trigger state changes via software.
If I want to measure RA4, or pin3, I can use the debugger to check the value of the PORTA register, and it shows a change of state corresponding to what I'd expect. PORTB and PORTC are also working normally.
However, for some reason, RA5 will always read 0, no matter what the input voltage at the pin is (I've verified 4.8V at the pin with a multimeter). At first I thought maybe I damaged my input via ESD, so I changed to another IC of the same model (I ordered 3 from Digikey), and the problem persisted. I changed to the 3rd and final chip, but the problem was still there.
I've been trawling the microchip forums for answers, but no avail so far. Any advice is appreciated!