18F97J94 Uart-Input Error

Thread Starter


Joined Jun 16, 2022
I'm currently working on a project with 18F97J94. My design was working perfectly, then I added a discrete LCD module to the project and it work fine as well. but then I noticed when I use " UART4_INIT(115200) " somehow RH4 PIN is stops working as input. But when I define it as output there is no problem. The thing that I don't understand is RH4 pin doesn't have any connection with EUSART registers. Does anyone have an idea what's wrong with it?
(I also manually disabled CCP2,AN12 and LCD registers)
Compiler: MikroC

You don't say, exactly, so I am assuming that you want RH4 to be a digital input.
When it stops working, does it read as a 0 or a 1?
What is driving the pin? What's the impedance?
Are you verifying that the voltage on the pin is what you expect? Remember these are Schmitt-trigger inputs so there is some hysteresis. Check with an oscilloscope or a meter. A logic analyzer may not display the same level that the PIC "sees".
Looking at the data sheet, I think these are the only requirements to use RH4 as a GPIO input.

TRISH4 = 1
ANCON2 bit ANSEL12 = 0 Note that this pin is a 1 at power-up and you must explicitly clear it
The LSB of LCDSE5 must be zero
The port also has switchable pull-ups controlled by PADCFG bit RHPU
Read the value from PORTH, not LATH.