2016-06-21 01:28 PM
Hello,
I have used a timer for triggering ADC for sampling per 20uS and use DMA to transfer 100 sample to the array. I suppose that the total time of converting and sampling time for ADC is about 2uS. So at each 20uS I can transfer 10 samples to the array with DMA. I want to know that does the ADC stop the conversion at the end of 20uS or it continues the conversion and transferring the data to the array until it fills the whole array ? Is it possible to force the DMA to transfer the converted values to the zero index of the array at the start of each triggering? I dont know the order of transferring the converted values to the array with DMA at the start of each triggering? Regards Hamed2016-06-21 04:11 PM
That is a rather awkward explanation, which seems internally inconsistent.
So 100 samples, 10 samples, a 20us rate or 2us rate? Or 10 samples at each 20us trigger. You could pair two timers to create suitable pulse trains. You could enumerate 10 channels for the ADC to sample on each trigger. The design is synchronous, you can set up DMA to buffer one or two arrays of 10 or 100 samples, you could use HT and TC DMA interrupts to manage the arrival of the data. Perhaps you can diagram what you want better, or illustrate with code?2016-06-22 03:04 AM
Sorry for bad explanation.I want to measuring the voltage and temperature and current of one switching power supply. The switching frequency changes about 10khz to 200 khz.
First Question: I want to trigger the ADC immediately after the rising edge detection and stop it immediately after the next rising edge detection. Can I do it with the capture at channel1 of TIMER1? please suggest the correct way to do it. Second Question: I have 3 input for ADC sampling. two of them is dc voltage (one for measuring voltage and another for temperature)with switching spike with 10khz to 200khz on them. the last input is a sin wave that I must calculate RMS for it. the I want to skip the switching spike on the measured inputs. So I want to start the ADC converting with the rising edge of the square wave (Simultaneous
with sin wave ) and stop it with the next rising edge . I use DMA for transferring 300 converted value to one array. The TIMER1 input capture event occurs, but doesn't trigger the ADC. For each converted value I use 100 position of the array. /* TIM1 configuration ------------------------------------------------------*/ /* Time Base configuration */ TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); TIM_TimeBaseStructure.TIM_Period = 0xFF; TIM_TimeBaseStructure.TIM_Prescaler = 0x4; TIM_TimeBaseStructure.TIM_ClockDivision = 0x0; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure); TIM_ICInitStructure.TIM_Channel = TIM_Channel_1; TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising; TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI; TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1; TIM_ICInitStructure.TIM_ICFilter = 0x0; TIM_ICInit(TIM1, &TIM_ICInitStructure); /* TIM enable counter */ TIM_Cmd(TIM1, ENABLE); .. /* ADC1 configuration ------------------------------------------------------*/ ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; ADC_InitStructure.ADC_ScanConvMode =ENABLE ; ADC_InitStructure.ADC_ContinuousConvMode = DISABLE; ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_NbrOfChannel = 3; ADC_Init(ADC1, &ADC_InitStructure); Regards Hamed2016-06-22 06:35 AM
Hi shams.hamed,
I start the ADC conversion using HAL_ADC_Start_IT() or HAL_ADC_Start_DMA() functions after starting the Timer using HAL_TIM_Base_Start(). To get things more clear for you, I recommend that you take a look to the ADC examples in the . -Hannibal-2016-06-22 11:03 AM
I'm not looking to get heavily involved in your design work.
I might approach this by doing some continuous sampling of the signals in question, and using the timer or timers to timestamp the events in question, and then correlate that with the data stream from the ADC. ie using the ADC as a sufficiently deep FIFO, and then pulling out the data for the cycle(s) I was interested in, and processing that.To gate the ADC on/off would require you create a master/slave TIM arrangement.2016-06-22 01:19 PM
Hi clive1
How can I stamp the position of data in the array that DMA is transferring to the array at the rising edge of capture? I dont know how can I detect the right position of the transferred value by DMA to the array? If I know it, I can save the index of the array at the TIM1_IRQHandler and then pulling out the data for the cycle(s) I was interested in, and processing that. Is it true? Regards2016-06-22 01:57 PM
It is a synchronous machine, all the clocks have clear interrelationships.
One could read the TIMx->CNT phase during the DMA HT and TC interrupts2016-06-22 03:20 PM
Can you describe for me the Transfer Complete interrupt and when it happens ,please?
For example: The length of array which in our example is equal to 100. DMA is used to transfer converted values to the array. When did the ''Half Transfer'' and ''Transfer Complete'' interrupt happen?2016-06-22 05:17 PM
If DMA is set up for 100 transfers, HT (Half Transfer) will occur after 50 have taken place, and TC (Transfer Complete) when 100 have taken place. In circular mode this will continue as the buffer cycles.
2016-06-23 01:06 AM
Example : The input signal is a dc voltage with the spike on it that its frequency is equal to100 Khz .
With the total conversion time equal to 2us I have 10us/2us=5 converted values at each period. As you know I have 100 position for the array. So the DMA interrupt did not occur! Is it true? What is your opinion? I think about reprogramming the DMA start address to zero at the rising edge of the counter(the input of this capture/counter is a square waveform thatsynchronize
with the spike frequency). Can I change the DMA writing address with the below command?DMA_SetCurrDataCounter(DMA1_Channel1,0);
Is it work?
Then after next rising edge of input pulse I get the current DMA address.
Finally I can process the stamped array. Is it true?
please tell me your comment.
Regards