Hi Andrej Nastran,
If your input wave which already meet your PWM demand, then you just need to use the comparator to judge the voltage to output the High level or the Low level, then You don't need to control it in the MCU after you initialize the comparator, because this comparator it the hardware module in the MCU.
But if you want to change the input wave, and need to do other things, you need to use the other MCU code, just depend on your application.
Of course the comparator can shutdown the output, but you need to control the code.
Do you still need to use TPM? If you use the TPM, it can out put the PWM directly, you don't need to use the CMP to generate the PWM by judging the input voltage level. There are the different question, but from the boost topology, you can use the TPM send the PWM to the MOSFET directly, I don't know why you need to judge the 4V, then use the comparator.
Wish it helps you!
If you still have questions about it, please kindly let me know!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------