I'm using an STM32 for AC dimming, for which I use a GPIO output (or timer channel out) to drive a triac, whenever I get a zero crossing detection (rising edge). Is there a way to solve this only using timers architecture and without firmware overhead?i.e not using interrupt handlers.
- Toff -> configurable.
- Tonn -> remains the same.
Best Answer
You can put a timer (A) in single shot triggered from an external pin.
This external pin is your zero crossing detector.
You also may need a timer (B) to measure the frequency.
Software still needs to calculate the duty cycle percentage based on the frequency. And set timer A reload to the measured value in timer B.
However, you could use a DMA operation triggered by timer A to copy the capture time of B to the reload register of A. But, you're calculating with those numbers anyway.
Having an ISR called at 50Hz isn't a problem when it doesn't take a lot of time to process it.