Earlier, I was using the following configuration to update the SWOCTRL. With this configuration SYNCHOM is set to 0. I faced a problem that the commutation continues to work for 1 hour to 1 day but during this time period, their used to come a time where the BLDC motor used to be stopped. After debugging, I found out that the OUTMASK gets updated but SWOCTRL used to be on the old value.
Could you shed some light on what could have gone wrong.
Our understanding was that maybe the clock was on the boundary when OUTMASK is updated and SWOCTRL is left behind but it still doesnt explain that with next clock boundary, it should also get updated, but it didn't.
// Configuration for Register Value Update
const ftm_user_config_t flexTimer_pwm_InitConfig =
{
{
true, // Software trigger state
false, // Hardware trigger 1 state
false, // Hardware trigger 2 state
false, // Hardware trigger 3 state
true, // Max loading point state
false, // Min loading point state
FTM_SYSTEM_CLOCK, // Update mode for INVCTRL register
FTM_SYSTEM_CLOCK, // Update mode for SWOCTRL register
FTM_SYSTEM_CLOCK, // Update mode for OUTMASK register
FTM_SYSTEM_CLOCK, // Update mode for CNTIN register
true, // Automatic clear of the trigger
FTM_WAIT_LOADING_POINTS, // Synchronization point
},
FTM_MODE_EDGE_ALIGNED_PWM, //!< Mode of operation for FTM
FTM_CLOCK_DIVID_BY_128, // FTM clock prescaler
FTM_CLOCK_SOURCE_SYSTEMCLK, // FTM clock source
FTM_BDM_MODE_00, // FTM debug mode
false, // Interrupt state
true // Initialization trigger
};
// ISR for BLDC commutaiton
uint8_t private_hal_mc_actuate_set_pwm_mask(uint8_t ui8OutMask, uint16_t ui16SwCtrl)
{
FTM_DRV_MaskOutputChannels(3/*INST_FLEXTIMER_PWM3*/, ui8OutMask, false);
FTM3->SWOCTRL = ui16SwCtrl;
return 1;
}