PDA

View Full Version : HPWM - I need 10 bits



BrianT
- 26th September 2007, 06:24
Hi,

I have a problem with an 18F4620 project where the 8 bit PBP HPWM command is just too coarse. I really need 10 bit resolution to solve this.

Does anyone have a code snip that shows how to drive the ECCP module for ten bit PWM resolution that they are prepared to share?

Cheers
Brian

Kamikaze47
- 26th September 2007, 08:32
Look at pages 144-146 in the 18F4620 datasheet. It will tell you how to set up all the required registers. Specifically the section "15.4.4 SETUP FOR PWM OPERATION" tells you step by step exactly what to do.

*edit* If after reading thru those pages you are still stuck, let me know what PWM frequency and duty cycle you are after and i'll help u out with some code.

mister_e
- 26th September 2007, 12:59
PICMultiCalc will help to calculate the registers value, but yup, you still need to open the datasheet and make sure you place them at the right place.

http://www.mister-e.org/pages/utilitiespag.html

few example
http://www.picbasic.co.uk/forum/showthread.php?t=6300&highlight=duty&page=2

HTH

BrianT
- 26th September 2007, 13:15
Does anyone know if it is possible to set up HPWM in PBP then fine tune the values with a direct write to CCP1CON<5:4> which control the two LSB?

This would let me stay with the PBP code I have and add a 'simple?' tweak where the 8 bit steps prove too coarse?

Cheers
Brian

Kamikaze47
- 26th September 2007, 13:31
You could try it, but I cant think of an easy way to test if it worked unless you have a scope handy to look at the output.

Frankly, its not hard at all to set it up by directly writing to the registers. If anything it would be a good learning experience, as i'm sure this wont be the last time you will have to deal with registers like these.