Check engine light after changing battery, and P0171.

Changed the battery in our 99 Cavalier yesterday. The car was hard to start, and set two codes. One was missing crank position sensor, the other was cam
position sensor low output. I reset the PCM and it seems to be fine. Could changing the battery somehow upset the PCM? The battery was out of the car for about a half hour. Figured the computer would have to relearn the engine but did not expect this.
Also our 2001 Prism set P0171. Any hints on why it might think it is lean? This car pings under very light acceleration, has for years. Going to switch brands of fuel for a while. The manual mentions too much alcohol or water in the fuel causing this??

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
Add image file
Upload is a website by car enthusiasts for car enthusiasts. It is not affiliated with any of the car or spare part manufacturers or car dealers discussed here. All logos and trade names are the property of their respective owners.