This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Can you use two GPIOTE channels for the same pin?

I'm trying to output a relatively high frequency PWM (300kHz). I'll need to adjust the duty cycle on the fly, without glitches and minimal time spent in IRQ handlers.

Currently, I have 2 compare matches setup on a timer. Each event triggers the same GPIOTE task which toggles the output. I also have the timer clear short setup. This works fine for a constant duty cycle.

However, when I want to change the duty cycle, and I do regularly, I need to wait until the right time in the timer cycle so that an extra compare event doesn't trigger an extra toggle and invert my duty cycle. It's difficult for me to afford to spend time sitting around for the right time in the timer cycle to set things.

My question lies in trying to fix this. I noticed that the GPIOTE can be configured to only toggle high-to-low or vice versa. My hope was to use two GPIOTE channels for the same IOpin each with a dedicated timer compare and PPI channel and one setup to "set" the output with the other setup to "clear". I know this uses an extra of the precious 4 GPIOTE channels, but that cost is worth it for me if I can then make duty cycle corrections faster.

However, when I tried to do this, the GPIOTE hardware would only let one control each IOpin. My question is, is it possible to configure GPIOTE differently so that I can do what I want? Did I miss some configuration? If you are using GPIOTE in set/clear mode, is it only meant for one shot? Would you need to reconfigure the GPIOTE channel for the next transition? Seems like a very silly mode with only a couple use cases.

Related