Hi @HARINI_T!
The issue you are experiencing is due to a synchronization mistake. Let me explain:
You initialize the FTM with the default configuration using:
FTM_GetDefaultConfig(&ftminitialisation);
This configuration is set up with a software trigger to update the registers:
/* Software trigger will be used to update registers */
config->pwmSyncMode = (uint32_t)kFTM_SoftwareTrigger;
Therefore, you need to provide the trigger in your code in order to update the registers.
This is because several FTM registers (including FTMx_CnV) have a buffer and cannot be directly written to when addressed by the software in order to ensure a properly synced write of the register:
“In output modes, writing to a CnV register latches the value into a buffer. A CnV register is updated with the value of its write buffer according to Registers updated from write buffers.” (p. 849 of RM).
When using:
FTM_UpdatePwmDutycycle(BOARD_FTM_BASEADDR, FTM_Channel_0, 0U, g_d0);
you are only writing the new value on the buffer, so you need to create the software trigger to write the value that is currently stored in the buffer, into the actual register. This can be done with the following function:
FTM_SetSoftwareTrigger(BOARD_FTM_BASEADDR, true);
For more information about the buffer and register synchronization requirements, please see Chapter 38.3.11 “Synchronization (FTMx_SYNC)” of the Reference Manual.
Always a pleasure to help,
Edwin.