Post the whole code here!

Be sure you disable ALL analog stuff on this 'unknown' S_Pin

Internal osc or external?

Did you try to connect your BS2 to your PC?