On Thu, 6 Mar 1997, Jean-Francois Joly wrote: > Hello there! > Do you know how I could use the timer with PWM? I know some people did it with > the timer but Im not sure how they did it... > > TTYL! > Jean-Francois > Hi !!! i don't have the working code for the PIC but i can tell you the basic idea of PWM. what you do is you start the counter and at the same instant set some port bit to one (i.e. high). then you keep on comparing the timer value with the digital value, which is supposed to modulate the pulse width. e.g. it could be the digitised feed back voltage in a PWM controlled poer supply. the moment the value of the timer becomes equal to the digital value, port bit is reset to zero. now the port bit will remain low untill the timer overflows. after which new cycle starts. so note that the pulse width is effectively proportional to the value of the digital word. larger the digital value more time the timer will take to reach the value and hence the pulse width will be larger. with the serial ports of 16cxx PICs, it should be easy to get the PWM. i hope you got some idea about the pulse width modulation. cheers, vishram. +------------------------------------------+ | Vishram A. Sarurkar | | ^^^^^^^^^^^^^^^^^^^^^ | | another hobbyist turned researcher | | slogging @ Indian Institute of Science | | ----------- | | e-mail:vish@isu.iisc.ernet.in. | | Phone:+91 (080) 3092487. | +------------------------------------------+