Without knowing which processor, I can't dig through the datasheet....but every time this has happened to me it turned out to be some other peripheral (such as something remapped using PPS, or the ADC, etc) which is overriding the TRIS setting on that port.. If you can share which controller/variant, I might be able to see something more specific to suggest. On Wed, Nov 6, 2019 at 4:15 PM David Van Horn < david.vanhorn@backcountryaccess.com> wrote: > I'm having what seems a pretty bizarre problem. > I'm using bit 14 of port A as an input to tell me when I need to pick up > data from an ADC. > I am absolutely sure the pin is toggling low, but when I read the pin it'= s > always 1 in the port register. > I'm aware of the AD1PCFG register which could cause this, but AFAIK that > only affects PORTB > Fortunately, I'm using the PICKit4 ICE, so I can see the register states > as commented below. > My init routine sets TRISA bit 14 high, and that's all that should matter= ... > > What would cause bit 14 of PORTA to always read high when the pin itself > is low? > > > int ADC_Check_Data() { > int temp =3D 0; > > temp =3D PORTA; // Get the pin states > // temp =3D 0x0000C0FF at this point, bit 14 is high though the pin > itself is LOW. > temp &=3D (1 << 14); // mask off all but bit 14 > // Here I always get 0x00004000 Bit 14 is HIGH when the pin itself is > LOW. > // AT THIS MOMENT: > // LATA =3D 0x0000C0FF > // ODCA =3D 0x00000000 > // PORTA =3D 0x0000C0FF (shows bit 14 =3D HIGH) > // TRISA =3D 0x0000C0FF (shows bit 14 as INPUT) > // Low =3D data ready for reading. > if (0 =3D=3D temp) { > return 1; > } else { > return 0; > } > } > > > > -- > David VanHorn > Lead Hardware Engineer > > Backcountry Access, Inc. > 2820 Wilderness Pl, Unit H > Boulder, CO 80301 USA > phone: 303-417-1345 x110 > email: david.vanhorn@backcountryaccess.com david.vanhorn@backcountryaccess.com> > > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 - Forrest --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .