So a brief (maybe) rundown on the pertinent stuff. To start with the TCCM sends out a 5 volt signal voltage to the dashboard selector switch and both a 5 volt and a low reference ground to the position sensor down at the transfer case shift motor. When the dash switch is moved it sends back a lower voltage to the TCCM. This is how the TCCM know what range is desired by the position of the switch on the dash. Similarly the range position sensor inside the transfer case shift moter (encoder motor) sends back a less than 5 volt signal reporting the current position of the transfer case & shift motor. If either of these sensor/switches get worn or dirty the signals back to the TCCM don't really represent what the true state of the devices are. Failing or otherwise faulty connections produce erratic behaviours.
I find checking the switch and range position sensor return voltages via a bluetooth OBD2 adapter and the Torque Pro Android app the easiest way to see what's going on with the inputs to the TCCM. It requires some custom setup as it does not come with these capabilities.
Second easiest way I know is to use a multimeter and backprobing the connections at the TCCM. This requires knowing which wire(s) to check and having something to probe with. An actual backprobe set is nice but it can be done with other things like a piece of small gauge wire or a needle with alligator clip jumpers.
So for the encoder (range position sensor) return one would read the voltage between C1, B6 and C1, A7. You can substitute a known good ground for C1, A7. For the dashboard switch read the voltage at C1, A6 and ground.
View attachment 101351
The voltages should be close to these values...
View attachment 101352