Timer with a relax period
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-06 11:17 AM - edited ‎2024-06-06 4:23 PM
HI
I need a simple timer that can make a PWM signal BUT with custom pauses or a relax period every number of pulses ... I have the code working very well with no relax , but I do not know how to write the relax period in the timer script itself...
Here is my actual code :
void SwitchPulse(){
TimerPulse.pause();
PeriodCyc = (Current[curMark] + Current[curSpace]) * (F_CPU/1000000.0);
Prescaler = (PeriodCyc / MAX_RELOAD) + 1.0;
TimerPulse.setPrescaleFactor(Prescaler);
Overflow = (PeriodCyc + (Prescaler / 2.0)) / Prescaler;
TimerPulse.setOverflow(Overflow);
DutyCyc = Overflow*Current[curMark]/(Current[curMark]+Current[curSpace]);
pwmWrite(PinPulse,DutyCyc);
TimerPulse.refresh();
TimerPulse.resume();
}
I wonder if it can be done more directly with the timer registers...
- Labels:
-
STM32F1 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-06 11:21 AM
You could perhaps use a pattern buffer for CCRx values that load via DMA triggered on the Update.
Then the length and circular nature of the buffer could be used to modulate the PWM active, and PWM inactive sequences/counts generated at the pin.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-06 11:25 AM
Thanks for the response... Any example of how to do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-06 11:46 AM
15+ Years ago, perhaps using SPL, today in Arduino, No
You could modulate the TIMx->CCRx settings in the Update interrupt too, if DMA isn't practical
Up vote any posts that you find helpful, it shows what's working..
