LEDC timer overflow interrupt
-
- Posts: 1
- Joined: Thu Feb 08, 2024 10:31 pm
LEDC timer overflow interrupt
Hello, im doing a project for a JBC controller, and im using ESP32-S3, i was using LEDC to drive the heater of the iron bye a pwm signal, the way the JBC handles are build, the heating element and the temperature sensor share a pin, and temperature readings cant be done while powering the heating element, so i need to take a sample from the adc when the pwm is in the off state, i want to have an interrupt on the overflow of the pwm timer to take the adc sample but im not finding information about that, i just find information about the fade interrupt, which i believe is not what i want, i have read the datasheet and in the LEDC peripheral there i a bit for the timer overflow interrupt, is there some API i can use to do that?
-
- Posts: 1708
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: LEDC timer overflow interrupt
Apparently, there's no API for the LEDC interrupts except for fade_end, not even in the HAL. Plus, the LEDC has only one interrupt signal, i.e. only a single interrupt vector/ISR, and the LEDC driver already grabs that single interrupt.
Of course, you can 'hack' the LEDC driver, 'inject' your own ISR (e.g. via the linker's '--wrap'), or replace the driver's ISR at runtime; probably overkill for your case.
The MCPWM can also generate PWM output but is much more complex than the LEDC.
Given the comparatively large time constant of your 'system', the 'best' option for your case may be to just use a timer and generate the PWM in software - no need for MHz-capable hardware PWM when of a couple of Hz would be sufficient, and the occasional jitter of a few microseconds is not an issue.
Pulse density modulation (PDM) may even be easier to implement and also give more 'accurate' results.
Of course, you can 'hack' the LEDC driver, 'inject' your own ISR (e.g. via the linker's '--wrap'), or replace the driver's ISR at runtime; probably overkill for your case.
The MCPWM can also generate PWM output but is much more complex than the LEDC.
Given the comparatively large time constant of your 'system', the 'best' option for your case may be to just use a timer and generate the PWM in software - no need for MHz-capable hardware PWM when of a couple of Hz would be sufficient, and the occasional jitter of a few microseconds is not an issue.
Pulse density modulation (PDM) may even be easier to implement and also give more 'accurate' results.
Who is online
Users browsing this forum: No registered users and 74 guests