> I've just switched over from using the old PIC16F84 to the PIC16F628. I > use PicBasic Pro for all my programs. > I just want to know if my thinking is correct... Since the 16F628 has > hardware PWM, is it possible for me to write a program in Basic where I > can output PWM pulses on several pins simultaneously while at the same > time listening for serial data on another pin? > i.e. Can I set the output pins and let the hardware maintain the PWM > pulses indefinitely without having to do any looping? > Thanks for any advice. > > Dan, > > Yes. The 628 PWM output is completely asynchronous to your code. Once > you set it up and turn it on, it continues on automatically. If you > wish to change the "duty cycle", all you have to do is write to PR2 and > it will take effect at the beginning of the next "period". > > michael brown BTW, the bummer is that the PWM mode of the capture/compare module uses TMR2, whereas the other modes use TMR1. This may or may not bother you. OTOH, it really torques me off, because you can't use the postscaler to stretch the "period" out. I have some example code if you want it, but the datasheet is fairly clear on the register setup. I tinkered with an R/C servo motor using the hardware PWM. Even though I was using a 4Mhz crystal, it still made the period way shorter than I wanted. The minimum period length (4Mhz) is around 5ms. I wanted a 20ms period length for the servo, but it still worked fine with my particular servo motor. YMMV michael -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.