You'll have to check that specific code first. However, its most likely a transfer case issue, and a common problem on electronic shift transfer cases is the the encoder motor that shifts the case. But don't start throwing parts at it until you pin-point the problem. Other common issues with the transfer case are speed sensors, dash switches and sometimes the transfer case control mondule. The only "cheap" thing in that list is the dash switch and even then its about $70. The encoder motor is about $500 last time I checked.
2012 Chevy 2500HD ECSB, 6.0L gas, auto, 4x4, LT
2003 F450, 7.3L PSD, 6 spd stick, 2wd, dump truck
1983 GMC K2500 pickup - working on a Cummins 5.9L swap
1987 GMC K3500 Dump, 6.2L diesel, TH400 auto - project plow truck