cancel
Showing results for 
Search instead for 
Did you mean: 

How to access the signal formation process when using DMA

macam1
Associate III

A signal is generated by a DAC DMA used on the STM32F405. Using a buffer containing an array [100]. As shown in the picture, the point (circle on the line) represents the point to be detected. This is only for detection, not to start and stop the signal.

In short, I want to detect when the array [45] "starts ignition detection" and array [50] "stops ignition detection". However, I'm still trying to figure out how to detect it because the DMA will directly generate the signal without me knowing exactly where it forms the array [45].

Do you have any suggestions or ideas on how to achieve this?

 

WhatsApp Image 2024-12-12 at 09.58.56_187f2753.jpg

 

4 REPLIES 4
MasterT
Lead

You can use another TIM as a counter.

Let say you already conected TIM1->DAC->DMA. So waveform generated with sampling rate defined by TIM1 clock.

Than chain same events  (that triggers a DAC conversion) to another timer like TIM1->TIM2 and set tim2 to fire interrupt when it's reach specific values 45 or 50. 

Timer 2 in external clock mode 1 (SMS=111 in TIM2_SMCR register).

But I want the counter data or array, not the sampling time.

Right, sync necessary. DMA generates 2 interrupt, HalfComplete (HT) and TransferComplete (TC). Just reset TIM2 inside TC interrupt subroutine. Than each sample transfered by DMA  'd corresponds to TIM2 CNT incremented value. There is also option to verify that system in sync, read DMA counter and TIM2 CNT and compare at any moments. I see learning is complicated, get youself more familiar with DMA, check what registers it has, what information available to read. Reference Manual (RM) for uCPU is your bible


@MasterT wrote:

Right, sync necessary. DMA generates 2 interrupt, HalfComplete (HT) and TransferComplete (TC). Just reset TIM2 inside TC interrupt subroutine. 


Taking into account the time between when DMA fired an interrupt and getting into the interrupt handler to reset the TIM2 counter there will be an amount of time that makes the mechanism is not well synchronized.

@macam1 are you using a timer to trigger DMA for each sample generation? for example using TIM2 and activate the 4 channels interrupt for output compare (with no output). Each channel will be specific to a array[x] position detection. As you have 4 values to detect, you need 4 channels as I said previously. And for each TIM Channel you need to compute the pulse value in a manner an interrupt will be raised when the TIM counter reaches a value that corresponds to array[x]. in that case you will treat the occurrence of the array[x] positions in the TIM interrupt output compare.

I don't know if that works but you need to test it.

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.