Take a look at post #6 at
http://www.picbasic.co.uk/forum/showthread.php?t=7962

Also, I am not sure about the way you control the Clock line in your code.