> First you must have a method to put the PWM output > on/off. The AP note uses the TRIS bit of RB4 for this. > Probably OK. You think the tristate should be flipped eh? Why not just use the duty cycle as a switch? You have a preference I take it? > > >>If that's the case, then how would you go about doing that? >>Would this require a second timer that runs at some "baud rate" >>that pulls data from a register and sends it out the pwm? > > > You don't have to tie up a hole counter for this, just > another software counter. A counter is a counter though. > > Note that each "bit" wil be a specific number of periods of the > PWM signal. So you can just as well count the number of PWM > periods output and, when the correct number is reached, just > shut of the PWM output. > > This can be done easily by using the "overflow interrupt" of the > timer controling the PWM module. In the ISR you then just > decrement a counter and, when it reach zero, shut the PWM output > off. I like that idea. I'll look in to it some more. Thanks. -Shawn > Using this method it's also easy to get clean on/off so you > always gets whole and clean PWM pulses. You could either also > control the "on" of the PWM in the ISR, or just monitor the > "timer interrupt flag" somewhare else in your code. > > I used this concept in an IR sender using the PWM module to > produce the 38Khz carrier, and using sequences of PWM > pulses of different length to idicate "start", "1" and "0" bits. > Looks very much the same as this application... > > Jan-Erik. > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads