cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to route a single bit from peripheral memory to an GPIO via DMA?

klauskvik
Associate II

Hi

I have an application where an ADC input is monitoring a signal. I would like to set an output if the ADC reading on a channel is above a certain value. Microcontroller in use is STM32F750V8, but is interested to know if this is also possible on the smaller micros (STM32F0 / STM32G0)

I can setup the Analog Watchdog, and trigger an interrupt on the ADC_SR AWD flag. Then in the ISR I can set the port pin

I would like to avoid the use of an ISR

Is it possible to use DMA to transfer the ADC_SR AWD bit to an IO directly?

It seems to me that DMA memory to memory could do this, when the peripherals are memory mapped. But, in that case, it is probably an entire byte that is transferred....?

Regards

Klaus

4 REPLIES 4
TDK
Guru

So you want to transfer a single bit within ADC->DR (say, bit 7) into a GPIO pin register? You can't do that. DMA can't transfer less than a byte.

Some chips have a comparator which can drive a digital output based on an input without using the CPU, but not the STM32F7.

If you feel a post has answered your question, please click "Accept as Solution".

While impractical, you could use DMA to transfer a whole byte or halfword - either from ADC_DR, or ADC_SR - to GPIO_ODR, where only one single pin - the one at the bit position in question - is set as GPIO Out (other pins being possibly In, AF or Analog). You wouldn't use memory-to-memory, but you would "normally" trigger the DMA from ADC upon conversion complete (in some STM32 some DMA don't have a route to GPIO, but you would use DMA2 in 'F7 which does).

The 'F7 is aimed at numbers crunching and it's relatively poorly equipped for analog signal processing. Other families (mainly 'F3 and 'G4, but to a certain extent also 'G0 you've mentioned) have a connection from the ADC watchdog to timers, which could be perhaps used for this purpose (maybe not completely straightforwardly, is the intended purpose is to have a safeguard switching off PWM when some voltage goes out of bounds). These families also have analog comparators which together with DAC can serve a similar purpose.

JW

klauskvik
Associate II

Thank you for your answers :)

We also have a STM32WB50, and it has Analog Watchdog also.

In addition it can route the ADC_WD_OUT signal to the ETR signal on a timer. So if I set the timer ETR input for the clock and set the reload counter to 0xFFFFh, I can let the counter overflow for each watchdog signal, and route the overflow output to a pin (or the compare output)

So, it seems it should be possible to do the signal generation without SW interaction

Doing bit level transfer from a peripheral isn't really what the hardware excels at.

Driving GPIO [upto 16 wide] from a pattern buffer is much more attainable, at high frequency and and without SW interaction.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..