Hi,
This question has to do with simultaneous starting three submodules of a single flexpwm. The goal is that the three submodules should be in sync.
From the results below, it seems I am missing something in how to start the three submodules together. Here is what I have:
First the code snippets for how they are being started. The full source is attached. (This is work in progress, it started as c code, but will probably redo it as a class after a few things are sorted out. So for now its not great on style. But I think it demonstrates the question.)
And here is the result:
This question has to do with simultaneous starting three submodules of a single flexpwm. The goal is that the three submodules should be in sync.
From the results below, it seems I am missing something in how to start the three submodules together. Here is what I have:
First the code snippets for how they are being started. The full source is attached. (This is work in progress, it started as c code, but will probably redo it as a class after a few things are sorted out. So for now its not great on style. But I think it demonstrates the question.)
Code:
inline void pwm_start_(IMXRT_FLEXPWM_t *p, uint8_t mask)
{
//p->MCTRL |= (FLEXPWM_MCTRL_RUN(mask) | FLEXPWM_MCTRL_LDOK(mask));
p->MCTRL |= FLEXPWM_MCTRL_RUN(mask);
p->MCTRL |= FLEXPWM_MCTRL_LDOK(mask);
}
inline void pwm_stop_(IMXRT_FLEXPWM_t *p, uint8_t mask)
{
p->MCTRL |= FLEXPWM_MCTRL_CLDOK(mask);
p->MCTRL &= ~FLEXPWM_MCTRL_RUN(mask);
}
Code:
void pwm_lccd_start()
{
pwm_stop_(icg_flexpwm,0xF);
//icg_flexpwm->MCTRL |= FLEXPWM_MCTRL_CLDOK(0xF); // stop everything
icg_flexpwm->SM[ICG_SUBMODULE].STS = ICG_CMPF_MASK; // clear any pending interrupts
cnvst_flexpwm->SM[CNVST_SUBMODULE].STS = CNVST_CMPF_MASK;
icg_skip_one = icg_skip_one_reload; // reset the clear gate
pwm_frame_counter = 0;
read_pointer = read_buffer; // reset the readout
read_counter = 0; // in case something this as a flag
icg_flexpwm->SM[ICG_SUBMODULE].STS = ICG_CMPF_MASK;
NVIC_ENABLE_IRQ(ICG_IRQ);
pwm_start_(tcd1304_flexpwm,CLK_MASK|SH_MASK|ICG_MASK);
//tcd1304_flexpwm->MCTRL |= 0xF<<8 | FLEXPWM_MCTRL_LDOK(CLK_MASK|SH_MASK|ICG_MASK); // Start clk, sh, icg only
pwm_frame_cyccnt_start = ARM_DWT_CYCCNT;
}
And here is the result: