Many thanks everyone. It was the TRISIO data. As you identified I didn't enable GPIO.5 as an input!
It was late and too much coffee. It didn't help the software acting as if the port was an input...

Now working as expected.

Thanks,
BobP