MCPWM - how to get the output state of PWMxA or PWMxB
Posted: Mon Dec 19, 2022 11:00 am
I have unique measurement device where an ESP32-Wrover is used to control and acquire signals in the application. I am using the MCPWM peripheral to configure a PWM signal for a LED diode. And I have photodiodes connected to an SPI ADC. The driving of the diodes and the acquisition must be synchronized. And there is configurable phase shift between the excitation of the LED and the sampling of the signal. A phase shift is implemented with a second channel of the MCPWM module (PWM0A is used to drive LED and PWM0B has a phase shift for evaluation algorithm). The SPI acquisition is going with a predefined period, at the end of transaction an interrupt is triggered and at this point I would like to sample the PWM0B signal. For SPI interface I wrote my low level driver by configuring the SPI interface on register level (based on the code of spi_ll.h).
My question, how can I get the status of the PWM0B signal?
I know I can easily read the GPIO state of the signal, but if I do not route out the PWM0B signal to any GPIO, then how can I access the state of the signal?
My application is complex, regarding the timing of the measurement and synchronization of PWM signals, so I do not look other solutions. I would just like to know if I can read any register to get the state of the PWM0A or PWM0B signals. I started to read the TIMER0 register, so I can get the state of the timer, but I have to apply a software logic, based on the configuration of MCPWM module, to decide if the PWM0B was on high level or low level during sampling of the TIMER0 register.
Any advice would be welcomed.
Thanks!
My question, how can I get the status of the PWM0B signal?
I know I can easily read the GPIO state of the signal, but if I do not route out the PWM0B signal to any GPIO, then how can I access the state of the signal?
My application is complex, regarding the timing of the measurement and synchronization of PWM signals, so I do not look other solutions. I would just like to know if I can read any register to get the state of the PWM0A or PWM0B signals. I started to read the TIMER0 register, so I can get the state of the timer, but I have to apply a software logic, based on the configuration of MCPWM module, to decide if the PWM0B was on high level or low level during sampling of the TIMER0 register.
Any advice would be welcomed.
Thanks!