Darrel,
Whats required to have 'glitch free' operation but with 8 bit PWM, can the include file be easily modified for 8 bit, or should i just multiply my desired 8 bit dutycycle by 4?
Darrel,
Whats required to have 'glitch free' operation but with 8 bit PWM, can the include file be easily modified for 8 bit, or should i just multiply my desired 8 bit dutycycle by 4?
Also, just testing on 16F887, at 4mhz,
@ HPWM10 1,_OUTDUTY,300 results in a PWM frequency of 10khz according to my o'scope ???
I see the duty cycle changing, but the freq is around 9-10khz?
The frequency must be a variable.
You can't pass a constant as the parameter.
And just shift left 2 (<<2) to use 8-bit values.
hth,
DT
Old thread but very relevant to my issue.
Can I use HPWM10:
1. On an 18F87J50?
2. And have it glitch free?
3. To make a pulse train that's 140mS long and have varying duty cycles within the pulse train?
In other words: 300uS on, 200uS off, 300uS on on, 200uS off, 130uS on, 370 uS off, 300uS on, 200uS off, 130uS on, 370uS off, 170uS on, 330uS off, 130uS on, 370uS off, etc.
Each bit is 500uS and I don't need to modify anything while the packet is being sent; I can modify right before the next one is sent.
Last edited by Christopher4187; - 16th June 2015 at 15:50.
If by “glitch free” you mean free of any resolution error, not every frequency or duty cycle you want to generate will be.
for any particular frequency, you need the pic’s clock frequency to tell you that.
This online PWM calculator can tell you:
http://www.micro-examples.com/public...alculator.html
whether or not you can change it for arbitrary duration for every pulse like that would be a tough one,
I don’t think that’s possible, but might be wrong.
Depending what else the chip has to do, it might be possible to use timer1 overflow that way.
Last edited by Art; - 18th June 2015 at 20:58.
Bookmarks