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!
MCPWM - how to get the output state of PWMxA or PWMxB
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: MCPWM - how to get the output state of PWMxA or PWMxB
You could use an unused GPIO. If you're not using a ESP32-Pico-xx SoC, GPIO20 is a GPIO that is internal-only and you can use it for that.
Re: MCPWM - how to get the output state of PWMxA or PWMxB
Hey,
thanks for the response. I am using the ESP32-WROVER-IE-N16R8 with ethernet connection and all digital output pins are used. The SENSOR_VN and SENSOR_VP does not have any connection in the design.
The wrover does not have GPIO20, can I use it still? Or is there any internal-used GPIO for this purpose?
Like, GPIO1, GPIO3, GPIO6, GPIO7 ...etc?
thanks for the response. I am using the ESP32-WROVER-IE-N16R8 with ethernet connection and all digital output pins are used. The SENSOR_VN and SENSOR_VP does not have any connection in the design.
The wrover does not have GPIO20, can I use it still? Or is there any internal-used GPIO for this purpose?
Like, GPIO1, GPIO3, GPIO6, GPIO7 ...etc?
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: MCPWM - how to get the output state of PWMxA or PWMxB
Yes, you can. It's an internal GPIO and (unless you use an ESP32-Pico SoC, which you are not) it's not used elsewhere to my knowledge.
Actually entirely *un*like those GPIOs, as those that you mentioned are used for other things (GPIO1 = U0TXD, GPIO3 = U0RXD, GPIO6/7 connect to flash memory etc). GPIO20 is not even available as a pin on the ESP32 chip in that model so you can freely use it for 'loopback', unlike the other pins you mention (if you use those you either crash the ESP because it can't talk to its flash, or you won't get proper serial communication anymore)Like, GPIO1, GPIO3, GPIO6, GPIO7 ...etc?
Re: MCPWM - how to get the output state of PWMxA or PWMxB
Cool, great. This simplifies a lot. Thanks.
Btw, is there any other "loopback" GPIO? And is there any documentation about this GPIO20?
Thanks!
Btw, is there any other "loopback" GPIO? And is there any documentation about this GPIO20?
Thanks!
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: MCPWM - how to get the output state of PWMxA or PWMxB
No, sorry. And there's not really any documentation on GPIO20 as it's a GPIO like any other; it just happens to not be bonded out to anything on non-Pico ESP chips. It's the only GPIO of this type, to my knowledge.
Who is online
Users browsing this forum: Bing [Bot], iParcelBox and 88 guests