Hi,

I don't know enough info about your paritcular project to tell if it is doable with a PIC or not - maby it is, maby it isn't. You asked how it was possible to send a serial message lasting 2ms and have the PIC output 200kHz PWM signal at the same time. I showed you one possible way of doing that - by using the CCP module to generate the PWM and the USART to send the serial message. That way I'd guess 99% of the CPU time is still available.

Of course the CPU needs to be involved even when using the USART but the difference in amount of involvement compared to bitbanging a character is massive. Really, all the CPU needs to do is load the USART TX-register with the character to be sent, takes one maby two instruction cycles then it can continue doing other thing while the USART sends the character. When the USARTs transmit buffer is ready for another character it sets a flag which you can either poll or have generating an interrupt.

To send something periodically you use another one of the PICs hardware timers setup to generate an interrupt at a certain frequency. The interrupt service routine then either does the whole thing, sending the message (usually not a good aproach) or it simply initiates the sending by loading the first character into the USART TX-register and activating the TX-interrupt so that when the first character is sent you get another interrupt so you can load the next character etc etc. When the whole message is sent the you deactivate the TX-interrupt.

In my servo drive project I've been working on for long time the PIC counts step- and direction pulses at up to ~100kHz, reads an incremental encoder at up to 2.5MHz updating a 32bit position register, runs the PID loop at 1220Hz, drives the output bridge with a 20kHz PWM signal, sends and recieves serial messages at 115200baud AND blinks a LED - all at "the same time". It's not done magically with a single command, you have to make it happen.

/Henrik.