2017-09-07 08:55 AM
Hi
I'm using a STM32F103ZE
I'm trying to configure DMA1 with ADC1 Channels 12 & 16.
The code below works i.e. when the DMA flags the DMA_Buffer contains 800 samples,400 for Channel_12 and
400 for Channel_16
However I only need a 4 samples for Channel_16Is there a way to configure the DMA1 to retrieve 400 samples on Channel_12 and 4 samples on Channel_16 ?ThanksLiam#define BUFF_SIZE 800
uint32_t DMA_Buffer[BUFF_SIZE];void ConfigConductivityADC (void)
{ADC_InitTypeDef ADC_InitStructure;
RCC_ADCCLKConfig(RCC_PCLK2_Div6);ADC_DeInit(ADC1);// ADC1 configurationADC_InitStructure.ADC_Mode= ADC_Mode_RegSimult;ADC_InitStructure.ADC_ScanConvMode= ENABLE;ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T3_TRGO;ADC_InitStructure.ADC_DataAlign= ADC_DataAlign_Right;ADC_InitStructure.ADC_NbrOfChannel= 2;ADC_Init(ADC1, &ADC_InitStructure);ADC_TempSensorVrefintCmd(ENABLE);ADC_DMACmd(ADC1, ENABLE);ADC_RegularChannelConfig(ADC1, ADC_Channel_12, 1, ADC_SampleTime_239Cycles5);ADC_RegularChannelConfig(ADC1, ADC_Channel_16, 2, ADC_SampleTime_239Cycles5);ADC_ExternalTrigConvCmd(ADC1, ENABLE);ADC_Cmd(ADC1, ENABLE);ADC_ResetCalibration(ADC1);while(ADC_GetResetCalibrationStatus(ADC1));ADC_StartCalibration(ADC1);while(ADC_GetCalibrationStatus(ADC1));}void ConfigConductivityDMA(void)
{DMA_InitTypeDef DMA_InitStructure;
/* DMA1 channel1 configuration ----------------------------------------------*/DMA_DeInit(DMA1_Channel1);DMA_InitStructure.DMA_PeripheralBaseAddr=ADC1_DR_Address;DMA_InitStructure.DMA_MemoryBaseAddr=(uint32_t)DMA_Buffer;DMA_InitStructure.DMA_DIR=DMA_DIR_PeripheralSRC;DMA_InitStructure.DMA_BufferSize=BUFF_SIZE;DMA_InitStructure.DMA_PeripheralInc=DMA_PeripheralInc_Disable;DMA_InitStructure.DMA_MemoryInc=DMA_MemoryInc_Enable;DMA_InitStructure.DMA_PeripheralDataSize=DMA_PeripheralDataSize_Word;DMA_InitStructure.DMA_MemoryDataSize=DMA_MemoryDataSize_Word;DMA_InitStructure.DMA_Mode=DMA_Mode_Circular;DMA_InitStructure.DMA_Priority=DMA_Priority_High;DMA_InitStructure.DMA_M2M=DMA_M2M_Disable;DMA_Init(DMA1_Channel1, &DMA_InitStructure);}Solved! Go to Solution.
2017-09-07 09:31 AM
>>Is there a way to configure the DMA1 to retrieve 400 samples on Channel_12 and 4 samples on Channel_16 ?
No.
You can play games with the Rank and sampling multiple times, but the ratio/trigger isn't going to work for you here.
Injected?
Use the other ADC?
Burn the memory, cherry pick values of interest?
Use less memory, manage in HT/TC interrupts?
2017-09-07 09:31 AM
>>Is there a way to configure the DMA1 to retrieve 400 samples on Channel_12 and 4 samples on Channel_16 ?
No.
You can play games with the Rank and sampling multiple times, but the ratio/trigger isn't going to work for you here.
Injected?
Use the other ADC?
Burn the memory, cherry pick values of interest?
Use less memory, manage in HT/TC interrupts?
2017-09-08 02:53 AM
I'm already using ADC2 for SD.
For now I'm going to just going to
Disable the DMA for Channel 12,
ReConfigure and take a reading on Channel 16 (takes ~0.4 ms)
ReConfigure DMA ADC1 for Channel 12
I only need to poll Channel 12 once every few seconds so this workaround will do for now.
Thanks for the Feedback
Turvey.Clive.002
I just needed to know that it was not possible.