Quote Originally Posted by Etcho View Post
Hello - I had a quick question and I was wondering if anyone would be able to help me out -

Is there a way to generate a 38Khz square wave on any of the 16F877A pins? I am a bit confused because the PBP manual briefly talked about not being able to generate over 32Khz using the FREQOUT command - I know the 16F877A also has 2 PWM modules built in but I also wasn’t sure if they were capable of it - the manual from my understanding indicates no but I have a feeling that there is some way to do it.

I am looking to use two IR LEDs pulsed out at 38Khz and two IR 38Khz receiver modules as simple object detection for a small autonomous robot - I don't have a whole lot of room on the PCB so I hope to avoid using the 555 Timer IC

Any info regarding this problem would be great - thanks

Oh one other question - Has anyone messed around with the radio shack 38Khz IR receiver module? All the ones I have gotten from them seem to not function so I ended up having to order a couple PNA4602M which do seem to work.

Note -

If I posted this in the wrong area it was by accident please don't flame
What is the clock on the '877?
Assume 20mhz...

High outputpin
pauseus 13
low outputpin
pauseus 12
do it again

high outputpin takes less than 1us
wait for 13us
low outputpin takes less than 1us
wait for 13us
the jump takes a bit more time than the high and low commands...
total = a bit more than 26us...
26us for the loop gives you an output square wave of about 38461hz (actually a bit less), which should be close enough for an IR receiver.

Of course this is only one way, a brute force method of doing it.
One better way would be to either set up the PWM module to handle it (which it will), or use the TMR0 module to do some interrupts to toggle an output bit, and the list goes on.