2009-11-05 07:19 AM
Multi channel ADC
2011-05-17 04:29 AM
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
seems wrong becouse destination address needs increment Further, I cannot see any reason, why the STM Examples always redefine their own headers inside main.c Instead of #define ADC1_DR_Address ((vu32) 0x4001244C) try: DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&ADC1->DR; [ This message was edited by: Janvi on 05-11-2009 10:49 ]2011-05-17 04:29 AM
Hi,
I use STM32F103T4 for voltage monitoring. I need all 10 channels. I modified an ADC example from the lib, please see the code below: /* Private macro -------------------------------------------------------------*/ #define ADC1_DR_Address ((vu32) 0x4001244C) /* Private variables ---------------------------------------------------------*/ ADC_InitTypeDef ADC_InitStructure; DMA_InitTypeDef DMA_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; vu16 ADC_ConvertedValue[10]; /* DMA Channel1 Configuration ----------------------------------------------*/ DMA_DeInit(DMA1_Channel1); DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address; DMA_InitStructure.DMA_MemoryBaseAddr = (vu32) &ADC_ConvertedValue; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; DMA_InitStructure.DMA_BufferSize = 10; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; 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); /* Enable DMA Channel1 */ DMA_Cmd(DMA1_Channel1, ENABLE); /* ADCx Configuration (ADC1CLK = 14 MHz) -----------------------------------*/ ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; ADC_InitStructure.ADC_ScanConvMode = ENABLE; ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_NbrOfChannel = 11; ADC_Init(ADC1, &ADC_InitStructure); /* ADCx Regular Channel_0-9 Configuration */ ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 1, ADC_SampleTime_1Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 2, ADC_SampleTime_7Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_2, 3, ADC_SampleTime_13Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_3, 4, ADC_SampleTime_28Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_4, 5, ADC_SampleTime_41Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_5, 6, ADC_SampleTime_55Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_6, 7, ADC_SampleTime_71Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_7, 8, ADC_SampleTime_239Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_8, 9, ADC_SampleTime_1Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_9, 10, ADC_SampleTime_7Cycles5); // ADC1 configuration (vref) ADC_RegularChannelConfig(ADC1, ADC_Channel_17, 12, ADC_SampleTime_239Cycles5); /* Enable ADCx's DMA interface */ ADC_DMACmd(ADC1, ENABLE); /* Enable ADCx */ ADC_Cmd(ADC1, ENABLE); ADC_TempSensorVrefintCmd(ENABLE); /* Start ADC1 Software Conversion */ ADC_SoftwareStartConvCmd(ADC1, ENABLE); while(1) { } My problem is only the first element of ADC_ConvertedValue[10] is updated. Could any of you point me what is missing/wrong with my code? Thanks in advance! Best Regards, Alex2011-05-17 04:29 AM
Hi,
Thanks for your help! It works fine. Best Regards, Alex2011-05-17 04:29 AM
When I use uint32_t, there is an error saying that it is undefined