2019-09-11 11:40 AM
Hi,
I´m trying to implement the synchronous pulse width modulation for my Bachelor-Thesis. Therefore the frequency of the pulse width modulation is variable.
I´m using the SPC560P44Lx, SPC560P50Lx microcontroller family.
So what I want to do is to adjust the Registers where the frequency is stored as the peak value of a counter.
This is how my 3 Flex Pwm submodule-registers are initialized;
for.....{
FLEXPWM_0.SUB[u08_counter].CTRL.R = 0x0400U;
FLEXPWM_0.SUB[u08_counter].CTRL2.R = 0x2000U;
FLEXPWM_0.SUB[u08_counter].DTCNT0.R = 50U;
FLEXPWM_0.SUB[u08_counter].DTCNT1.R = 50U;
FLEXPWM_0.SUB[u08_counter].INIT.R = 0xF7A1; <------ This Value has to be adjusted every sampling period
FLEXPWM_0.SUB[u08_counter].VAL[0].R = 0x0019U;
FLEXPWM_0.SUB[u08_counter].VAL[1].R = 0x085FU; <------ This Value has to be adjusted every sampling period
FLEXPWM_0.SUB[u08_counter].VAL[2].R = 0x0U;
FLEXPWM_0.SUB[u08_counter].VAL[3].R = 0x0U;
FLEXPWM_0.SUB[u08_counter].DISMAP.R = 0x00FFU;
FLEXPWM_0.SUB[u08_counter].OCTRL.R = 0x0000U;
}
// Load the PRSC bits of CTRL1 and the INIT, and VALx registers into a set of buffers
FLEXPWM_0.MCTRL.B.LDOK = FLEXPWM_0_MCTRL_LDOK_LOAD_ALL;
// Fault registers setting
// Set the filter register to inactive
FLEXPWM_0.FFILT.R = FLEXPWM_0_FFILT;
// Clear the Fault flags
FLEXPWM_0.FSTS.R = FLEXPWM_0_FSTS_RESET;
// Set the Fault Control Register
FLEXPWM_0.FCTRL.R = PWM_FLT_CTRL_OFF;
Do I have to do the whole initializing process or is it possible to just adjust the the marked registers? If I can adjust these 2 registers, how? I´m new to this Chip and Software and I really reached the point of not knowing what to do.
Thank you for your help.
Best regards,
Michel