Thanks Darrell. I should have caught that channel number myself. I was able to test this thoroughly by incrementally changing the Vthr constant in the code and correspondingly incrementing the target voltage in the PICKIT2. It now works like a charm.

Thanks also for answering my question about the 6138/VDD calculation. I now understand the algorithm completely.

Let me say how much I appreciate your frequent and outstanding support to the forum. I use it extensively and really do appreciate it.