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,
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 14: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 19:58.
Bookmarks