Gast
#4824492
Hallo zusammen, ich sitze gerade vor einem Problem mit meinem STM32F107. Ich möchte über PB06 ein Potentiometer einlesen. Je nachdem welchen Wert dieses liefer, soll entweder die eine oder die andere eingeschaltet werden. Leider stelle ich bei Debugger immer wieder fest, dass an dem entsprechenden Eingang nichts ankommt. Hat jemand einen Tipp wo der Fehler liegt? Hier Mein Quellcode: #include<stm32f10x_rcc.h> #include<stm32f10x_gpio.h> #include<stm32f10x_adc.h> #include "stm32f10x.h" #include "stm32f10x_conf.h" int main(void){ GPIO_einschalten(); ADC_einschalten(); double poti = 0; poti = ADC_GetConversionValue(ADC1); if (poti > 2048){ GPIO_WriteBit(GPIOC, GPIO_Pin_0, Bit_SET); } else{ GPIO_WriteBit(GPIOC, GPIO_Pin_0, Bit_SET); } while(1){ } } void GPIO_einschalten(void){ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP ; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_10; GPIO_Init(GPIOC, &GPIO_InitStructure); } void ADC_einschalten(void){ GPIO_InitTypeDef GPIO_InitStructure; ADC_InitTypeDef ADC_InitStructure; RCC_ADCCLKConfig(RCC_PCLK2_Div6); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO | RCC_APB2Periph_ADC1, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB, &GPIO_InitStructure); ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; ADC_InitStructure.ADC_NbrOfChannel = 1; ADC_InitStructure.ADC_ScanConvMode = DISABLE; ADC_Init(ADC1, &ADC_InitStructure); ADC_RegularChannelConfig(ADC1, ADC_Channel_10, 1, ADC_SampleTime_1Cycles5); ADC_Cmd(ADC1, ENABLE); ADC_SoftwareStartConvCmd(ADC1, ENABLE); }