Oooohhhh.... not good...
The DEFEINE OSC 3 tells PICBasic that you're running at 3.58MHz, whereas you are actually running almost 110x slower at 32kHz...
This means that EVERY time critical function (including PULSEOUT) will be totally shot to pieces.
As a test... try this...
Loop:
High PortB.4
Pause 2
Low PortB.4
Pause 2
Goto Loop
You might find the LED blinks at about 2Hz (give or take)...
I don't recall if PICBasic (my manual is a little old) allowed definitions below 3.58 MHz... but I think 32kHz will cause numerous problems.
May I also suggest you SWITCH OFF the WATCHDOG TIMER (which is ON by default with PICBasic). The program may be running so slowly that your PIC is actually timing-out and resetting before it actually executes anything.




Bookmarks