Skip to main content
KKIM.6
Senior
Nov 1, 2022 3:25 PM UTC
Solved

Is it possible to generate a continuous square wave signal in the GPIO pin without extra order from CPU?

I realized that I would need continuously switching the GPIO pin for external MUX.

So, I want to know how to program continuously switching a GPIO pin (with a specific frequency and start timing for synchronizing with other GPIO pins)

However, If I on/off the GPIO pin with a delay, the timing doesn't match well.

So, is there any way to generate a frequency in a GPIO pin without any extra order such as DMA (it means that the GPIO pin just generates some signal without extra on/off control from the processor).

Is it possible? then what code should I use?

This topic has been closed for replies.
MM..1
MM..1Best answer
Super User
Nov 1, 2022 3:50 PM UTC

For this purposes is designed timers channels. Read en.STM32L4_WDG_TIMERS_GPTIM.pdf or any other. On your MCU you need use pin with alternate function TIMx CHy. And config ARR period and CCy duty.

9 replies

MM..1
MM..1Best answer
Super User
Nov 1, 2022 3:50 PM UTC

For this purposes is designed timers channels. Read en.STM32L4_WDG_TIMERS_GPTIM.pdf or any other. On your MCU you need use pin with alternate function TIMx CHy. And config ARR period and CCy duty.

KKIM.6
KKIM.6Author
Senior
Nov 1, 2022 4:00 PM UTC

Thanks for response.

I'll check the document!!

Tesla DeLorean
Guru
Nov 1, 2022 3:50 PM UTC

Don't the TIM do that?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
KKIM.6
KKIM.6Author
Senior
Nov 1, 2022 3:58 PM UTC

I have to control 35 GPIO pin for the 32x32 photodiode array for the image sensor array. I'll check TIM again but I'm not sure whether I can use TIM for 35 GPIO pin.

Tesla DeLorean
Guru
Nov 1, 2022 4:05 PM UTC

Strikes me you're using the wrong hardware for the task, perhaps you and your team can re-evalutate your approach?

You can use DMA+TIM+GPIO to drive a memory based pattern buffer against a bank of GPIO pins. Perhaps different DMA off alternate channels of one TIM to keep the phase relationships relatively tight.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal
Nov 1, 2022 4:26 PM UTC

Which STM32 is being considered?

KKIM.6
KKIM.6Author
Senior
Nov 1, 2022 4:37 PM UTC

I'm using STM32WB55VGY6TR.

I've already made my custom board and I successfully programmed the microcontroller for wireless data transfer.

The only problem now is measuring part of the sensor such as ADC, amplifier, and MUX for multiple channels.