Re: 2004 GMC Envoy Rough Idle
how old is the battery? when you charged the battery did you check to see if the battery was good? is the charging system working correctly? Is the security
light on when it starts and dies?
If the battery, charging and starting systems are all good and working normally then you should check for a draw on the battery. Looking to keep the amp draw under 0.030 amps when all the modules are asleep. (cycled off)
Knock sensor won't kill your battery or make it so your engine won't start. (unless something extraordinary is going on) So don't worry about that code for now.
If you can't communicate with the computer now check that you have good voltage at the pin #16 in the OBDII connector in your car. Pin # 4 and 5 are both supposed to be grounds. If you have battery voltage on #16 (12+ volts) and good grounds at # 4 & 5 then start checking fuses.
a bad pcm is possible