cancel
Showing results for 
Search instead for 
Did you mean: 

DMA update request to ADC works with timer 2 but not with timer 6 on stm32f7

Reed Thompson
Associate
Posted on January 02, 2018 at 03:06

DMA update request to ADC works with timer 2 but not with timer 6 on stm32f7. The data sheet states that timer 6 should be able to generate a DMA request in section 25.2 in document RM0385. Can anyone confirm this is possible? I don't mind using timer 2 but for curiosity's sake. 

2 REPLIES 2
Posted on January 02, 2018 at 03:37

Section 25.2 in RM0385 Rev 6 talks about the DAC not the ADC

http://www.st.com/content/ccc/resource/technical/document/reference_manual/c5/cf/ef/52/c0/f1/4b/fa/DM00124865.pdf/files/DM00124865.pdf/jcr:content/translations/en.DM00124865.pdf

 

You want the ADC to trigger the DMA, and the TIM to trigger the ADC

Table 94 (section 15.6) described the ADC's External Trigger. TIM6_TRGO is mentioned, so you'd need to configure TIM6 and route one of the sources (Update, CC1, CC2, etc) to the TRGO (Trigger Output) functionality.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on January 02, 2018 at 04:03

Right, that was the idea. I am usingTIM6 to count up and then cause an update event. This then causes the ADC to convert and then send a DMA request to send the data to my buffer. I set an interruptHAL_ADC_ConvCpltCallback( ) andHAL_TIM_PeriodElapsedCallback( ) with nop's in them just to hit the breakpoint and prove I got somewhere or not. I always get to

HAL_TIM_PeriodElapsedCallback( ) but never break on HAL_ADC_ConvCpltCallback( ). When I use TIM2 or TIM8 it does work.

so as an implementation:

I use this in main( )

HAL_ADC_Start_DMA(&hadc1, (uint32_t*)rawData, bufferSize);
HAL_TIM_Base_Start(&htim6);�?�?

This in TIM6 setup

htim6.Instance = TIM6;
htim6.Init.Prescaler = 1;
htim6.Init.CounterMode = TIM_COUNTERMODE_UP;
htim6.Init.Period = 2250;
htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
...
sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;�?�?�?�?�?�?�?�?�?�?

This is ADC1 setup

 hadc1.Instance = ADC1;
 hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
 hadc1.Init.Resolution = ADC_RESOLUTION_12B;
 hadc1.Init.ScanConvMode = DISABLE;
 hadc1.Init.ContinuousConvMode = DISABLE;
 hadc1.Init.DiscontinuousConvMode = DISABLE;
 hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;
 hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T6_TRGO;
 hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
 hadc1.Init.NbrOfConversion = 1;
 hadc1.Init.DMAContinuousRequests = DISABLE;
 hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;�?�?�?�?�?�?�?�?�?�?�?�?