cancel
Showing results for 
Search instead for 
Did you mean: 

Copy input pin to output.

BCoch
Senior

What would be an efficient, low latency way to reflect the state of an input pin onto an output pin?

Is there anything more automated than configuring the input pin as an EXTI, then in the interrupt handler, reading it and setting the state of the output pin accordingly? Could it be done with a comparator or timer?

1 ACCEPTED SOLUTION

Accepted Solutions
berendi
Principal

A couple of other ideas

STM32L1 Routing Interface. These are analog switches intended for touch sensing. Activating two switches in one "touch group" connects the two pins internally.

Timer + DMA to GPIO. Works when DMA is able to write the GPIO registers, target can be any pin. E.g. on STM32F4, TIM1 or TIM8 Channel 1 triggers on TI1 rising edge, Channel 2 on falling edge. They can be assigned to different channels on DMA2. One DMA channel copies the pin set mask, the other one the pin reset mask to GPIOx->BSRR.

SPI with DMA to itself, when you need a specific delay. This again needs a DMA that can copy to/from anywhere. SPI in master mode, RX complete DMA request copies the value in the data register back to itself, creating a true shifter. STM32H7 SPI controller can do it by itself without DMA.

View solution in original post

12 REPLIES 12
Pavel A.
Evangelist III

Just wire them together?

S.Ma
Principal

Add SmartIO type functionality in the 2019 STM32 Wish list?

Comparator may be plausible.

Timer: input signal on CH1, slave mode set as external clock fed from TI1F_ED. ARR set to 1. One of the other channels set to output, one of the PWM modes, CCR=1. Delays and frequency/edge distance restrictions apply.

I too wonder, what's the point.

JW

berendi
Principal

A couple of other ideas

STM32L1 Routing Interface. These are analog switches intended for touch sensing. Activating two switches in one "touch group" connects the two pins internally.

Timer + DMA to GPIO. Works when DMA is able to write the GPIO registers, target can be any pin. E.g. on STM32F4, TIM1 or TIM8 Channel 1 triggers on TI1 rising edge, Channel 2 on falling edge. They can be assigned to different channels on DMA2. One DMA channel copies the pin set mask, the other one the pin reset mask to GPIOx->BSRR.

SPI with DMA to itself, when you need a specific delay. This again needs a DMA that can copy to/from anywhere. SPI in master mode, RX complete DMA request copies the value in the data register back to itself, creating a true shifter. STM32H7 SPI controller can do it by itself without DMA.

The point might be overriding a signal sometimes, otherwise letting it pass through. E.g. there is an external component that wants to signal a warning sometimes, and the MCU itself should be able to turn on the buzzer too.

S.Ma
Principal

Routing interface would be analog mux with serial resistance (no buffering).

BCoch
Senior

Thanks for the great suggestions, Berendi. I don't suppose the STM32G0 series has the routing interface?

Indeed the application is as you surmised. It's for a test fixture, that can be in either an active mode, where the microprocessor is driving a signal, or in a passive mode, where an externally generated signal should be "passed through" instead. We could simply connect both external and internal together, tri-stating the internally generated one when in passive mode, but there would be no protection if put in active mode while the external driver is still connected.

David Viens
Associate II

Looking for an answer to this as well

Basically what I need to do offload in DMA what I can do in code but need the CPU for something else.

While using an STM32 as a switch or router is a silly idea, it could save on BOM a lot and make it more flexible.

In short in CERTAIN circumstances in my design (silly to justify adding a 16pin switch to BOM) I need to mirror as FAST as possible one GPIO port's inputs to another port's outputs:

while(1)

GPIOx->ODR=GPIOy->IDR;

}

What are the real options here?

1)Memory To Memory DMA could do this, but only once if at all since you can't use circular mode.

2)memory to perif or perif to memory can accept two GPIO ports?

3)one DMA that does GPIO to memory and another from that memory to another GPIO? (one 16bit word of memory only?)

4)something never explained on H7's MDMA could do this?

This is driving me nuts. Surely it can be done? (STM32F7 and H7 here)

As OP hinted, using the comparator is maybe the simplest and easiest way.

JW