> -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf > Of RNGolding@aol.com > Sent: 10 May 2011 14:41 > To: piclist@mit.edu > Subject: [PIC] How to achieve 10 bit PWM resolution at various > frequencies? >=20 > Hi, my first request to the list, so please be gentle with me! >=20 > I have an application that requires generation of a 10bit resolution PWM > signal at various repetition > frequencies between 100Hz and 1kHz. The PWM duty cycle and repetition > frequency commands > will be received via the serial bus @ 115200 baud. >=20 > Required PWM frequencies are 105Hz, 140Hz, 300Hz and 1kHz, but other > frequencies may be > required in the future. >=20 > I'm currently using a PIC18F4423 (but that can be changed if unsuitable). > Generating a 10bit PWM at a single frequency is pretty straightforward > using > a suitable master clock frequency and Timer 2 values but > I can't see how to get other frequencies (via PR2 value) without losing > the > 10bit resolution. i.e. setting a PR2 register value below 255 to set the > other frequencies reduces PWM resolution. >=20 > I've read the data sheet 'till I'm blue in the face and can't see a way of > achieving 10bit resolution at the various > frequencies. >=20 > My present thoughts are to use two PICs. The PIC1 to generate the required > clock frequency for PIC2, > which generates the 10 bit PWM (PIC2 using fixed Timer 2 values). The PWM > duty cycle demand would > then be communicated from PIC1 to PIC2 via SPI or I2C bus. >=20 > Clumsy, but can anyone suggest a more elegant way of doing it? If available, you could probably use the CCP module in compare mode. This can be configured to automatically clear or set the CCP pin on a match condition as well as raise an interrupt. Within the CCP interrupt you would need to switch between these modes and reload the CCPR registers with appropriate values for the duty cycle and frequency you wish to operate at. Regards Mike =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .