David edeca.net> writes: >=20 > All, >=20 > I have just started using a 12F617 instead of the larger pin count 18F =20 > parts. I am using HiTech in Lite mode. >=20 > The code is here: http://pastebin.com/nrQDC224 with the compiled =20 > version here: http://pastebin.com/kibNLyZx >=20 > In main(), I get to line 170 (0x7F9 in the compiled version) and the =20 > status LED is lit. I can see this in MPLAB simulator and on the =20 > target board (if I use a while(1) afterward so it stalls). However, a =20 > few cycles later we get back to line 38 (0x765 in ASM) and for some =20 > reason the entire GPIO port is reset to 0x00. This happens both in =20 > the simulator and in the real hardware. >=20 > I have tried a number of different code variations for the same thing, =20 > which all compile to the same. However, in all cases the GPIO port =20 > gets set to 0x00. >=20 > Is there anything I am doing wrong in the code that means the GPIO =20 > port is reset? >=20 > David Hi David,=20 First, disclaimer: I do not use PIC12F617 nor HITECH-C.=20 Looking at your code, couple notes:=20 1. STATUS_LED should not flash, once set to 1 it should stay there (line 1= 70). There is no explicit code to set it to 0. 2. on line 38: you set GPIO1 to 1. The GPIO port is read-modify-right. So= that should set only GPIO1 to 1, the rest of the port should be 0 (specifically,= RA2 should be 0 since all other port bits are inputs). 3. line 38 is executed from within while(1) when you call IR_Pulse() on lin= e 160. 4. Maybe use a shadow variable for the port, then set/clear bits in the var= iable and set GPIO =3D shadow variable. =20 my $0.02 Sergey Dryga http://beaglerobotics.com --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .