PDA

View Full Version : 12F509 / 609 IR and speed control



Macgman2000
- 11th October 2009, 21:19
Hello All,

I have the 12F509 set up to interpret IR commands. It decodes 2 bytes and latches the correct logic to the ports to drive an H-bridge (driving a tiny pager motor). I would like to have at least 5 speed levels, but the problem I see is the serial 2 bytes that would essentially steal mcu time (sent across every 20ms @ 1200 bps). Since this body has no hardware (serial or PWM) everything needs to run at 4 Mhz. What is the best way to do this with the 509?

Any help would be appreciated.

Nick

Charles Linquis
- 12th October 2009, 01:51
First, I think it would be a lot easier if you chose a PIC with a real RS-232 port, but -

one way would be to set up a 416uSec interrupt, (one half bit time at 1200 baud) and then use a slight variation of one of the assembly bit-banging routines. An example can be found at

http://www.winpicprog.co.uk/pic_tutorial7.htm


The big problem is catching the first negative-going transition of the START bit on receive. You will need to connect the RxD line to a pin that has an
interrupt-on-change function.