Hallo,
besitze das STM32F4 Discovery Board und möchte einen ADC Port
initialisieren. In der STM Library ist nur ein Beispiel eines
ADC mit DMA dabei. Diesen benötige ich nicht. Möchte einfach
Werte aus dem ADC lesen. Benötige eine Samplingrate von etwa 500khz
bis 1Mhz.
Könnte mir jemand beim Initialisierungscode helfen?
Liebe Grüße
Daniela
Hast du überprüft, ob an PB0 auch wirklich dieser ADC Kanal ist?
Was hast du angeschlossen an diesem PIN?
Clock für GPIOA muss noch aktiviert werden!
// enable Clock for GPIOA
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA , ENABLE);
ansonsten sieh dir doch mal dieses Tutorial an
http://www.diller-technologies.de/stm32.html#adc
Das Tutorial leht sich an einen STM32F10X ich habe aber einen F4
beim F10X hab ich es auch schon hingebracht.
wieso muss ich RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA , ENABLE);
aktivieren wenn ich doch pin PB0 als ad wandler nutzen möchte.
Stefan!
A tried your code but I have 3 errors
the problems are with the Typedef structures (with GPIO,ADC_COMMON_INIT,
and ADC_INIT..)
"declaration may no appear after executable statement in block
Here is my adc config:
void adc_configure(){
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1,ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB,ENABLE);
GPIO_InitTypeDef GpioInit;
//---- POT B----------------//
GpioInit.GPIO_Mode =GPIO_Mode_AN; //AIN?
GpioInit.GPIO_Pin = GPIO_Pin_0;
GPIO_Init(GPIOB, &GpioInit);
//ADC
ADC_InitTypeDef ADC_InitStructure;
ADC_CommonInitTypeDef ADC_CommonInitStructure;
ADC_CommonInit(&ADC_CommonInitStructure);
//ADC1 CONFIG
ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
ADC_InitStructure.ADC_ScanConvMode = DISABLE;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConv =
ADC_ExternalTrigConvEdge_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfConversion = 1;
ADC_Init(ADC1, &ADC_InitStructure);
//ADC COmmon CONFIG
ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_CommonInitStructure.ADC_TwoSamplingDelay =
ADC_TwoSamplingDelay_5Cycles;
ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_2;
ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2;
ADC_CommonInit(&ADC_CommonInitStructure);
ADC_RegularChannelConfig(ADC1,ADC_Channel_8,1,ADC_SampleTime_15Cycles);
ADC_Cmd(ADC1, ENABLE); // Enable ADC1
ADC_SoftwareStartConv(ADC1); //Start ADC1 Conversion
ADC_StructInit(&ADC_InitStructure);
}
I don't know where's the problem, I tried to copy the Struct definitons
in other lines.. but it doesn't work... :(