2019-10-25 02:06 PM
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?
Solved! Go to Solution.
2019-10-26 05:00 AM
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.
2019-10-25 06:14 PM
Just wire them together?
2019-10-25 06:27 PM
Add SmartIO type functionality in the 2019 STM32 Wish list?
2019-10-26 03:07 AM
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
2019-10-26 05:00 AM
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.
2019-10-26 05:06 AM
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.
2019-10-26 10:45 AM
Routing interface would be analog mux with serial resistance (no buffering).
2019-10-28 08:36 AM
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.
2021-01-27 06:16 AM
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)
2021-01-27 08:16 AM
As OP hinted, using the comparator is maybe the simplest and easiest way.
JW