The most likely cause is the encoder on the transfer case. The following is from a
gm service bullitin. Just so happens , I just replaced one today on a 98 gmc jimmy.
The encoder is located on the left side of the transfer case , it is a part . Basically it is
an electric motor that shifts the transfer case. If you follow the information from my last
post you should be able to verify that this is the bad part. This is the most common part
to fail and cause the problem you describe.