This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

STM32F103RB ADC CODE

I'm trying to write a code for ADC but there are 2 problems:

1.''ADC_CommonInitTypeDef ADC_CommonInitStructure;'' something is wrong in there. Should i add a library?. I've added "stm32f10x_adc.h" but still have problem.

2.''GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AN;'' i'm gonna use this pin for Anolog input but there is a problem.
I'm looking forward to your help. Thank you!

#include "stm32f10x.h" // Device header

int main()
{ uint16_t adc_data; //12 bitlik adc verisini bulunduracak

GPIO_InitTypeDef GPIO_InitStructure; ADC_InitTypeDef ADC_InitStructure; ***ADC_CommonInitTypeDef ADC_CommonInitStructure;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);

GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_OD; GPIO_InitStructure.GPIO_Pin=GPIO_Pin_5; GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure);

***GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AN; GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0; GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; GPIO_Init(GPIOC, &GPIO_InitStructure);