I have one question. Why are you setting the TRIS register each time thru the loop?