Today I'll take some time to study the temperature sensor. Use ADC1 PA5 to implement Add the driver of ADC1 based on the previous post, as follows ADC1_Handler.Instance=ADC1; GPIO_InitTypeDef GPIO_Initure; __HAL_RCC_ADC12_CLK_ENABLE(); //ê1üADC1/2ê±ó __HAL_RCC_GPIOA_CLK_ENABLE(); // aGPIOAê±ó __HAL_RCC_ADC_CONFIG(RCC_ADCCLKSOURCE_CLKP); //ADCíaéèê±ó GPIO_Initure.Pin=GPIO_PIN_5; //PA5 GPIO_Initure.Mode=GPIO_MODE_ANALOG; //£a GPIO_Initure.Pull=GPIO_NOPULL; //2′éà- HAL_GPIO_Init(GPIOA,&GPIO_Initure); ADC1_Handler.Init.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV4; //4·μ£ADCCLK=PER_CK/4=64/4=16MHZ ADC1_Handler.Init.Resolution=ADC_RESOLUTION_16B; //16£ê ADC1_Handler.Init.ScanConvMode=DISABLE; //·é¨è£ê ADC1_Handler.Init.EOCSelection=ADC_EOC_SINGLE_CONV; //1±EOCD ADC1_Handler.Init.LowPowerAutoWait=DISABLE; //×ˉμí1|o1± ADC1_Handler.Init.ContinuousConvMode=DISABLE; //1±áD×a ADC1_Handler.Init.NbrOfConversion=1; //1×aú1òDòáDD ò2íê×a1òDòáD1 ADC1_Handler.Init.DiscontinuousConvMode=DISABLE; //DiscontinuousConvMode ADC1_Handler.Init.NbrOfDiscConversion=0; //2áD2éùí¨μàêya0 ADC1_Handler.Init.ExternalTrigConv=ADC_SOFTWARE_START; //èít′¥·¢ ADC1_Handler.Init.ExternalTrigConvEdge=ADC_EXTERNALTRIGCONVEDGE_NONE;//ê1óèít′¥·¢ ADC1_Handler.Init.BoostMode=ENABLE; //BOOT£ê1± ADC1_Handler.Init.Overrun=ADC_OVR_DATA_OVERWRITTEN; //óDDμêyYμàoó±ó2μéêyY ADC1_Handler.Init.OversamplingMode=DISABLE; //1y2éù1± [font=微软雅黑, 微软雅黑, ADC1_Handler.Init.ConversionDataManagement=ADC_CONVERSIONDATA_DR; //1òí¨μàμêyY±£′úDR′÷à HAL_ADC_Init(&ADC1_Handler); //3êˉ HAL_ADCEx_Calibration_Start(&ADC1_Handler,ADC_CALIB_OFFSET,ADC_SINGLE_ENDED); //ADCD£× increase while adcx=Get_Adc_Average(ADC_CHANNEL_19,20);// temp=(float)adcx*(3.3/65536); // Compile and run See the figure below for wiring
This content was created by EEWORLD forum user star_66666. If you need to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the sourceOversamplingMode=DISABLE; //1y2éù1±
ADC1_Handler.Init.ConversionDataManagement=ADC_CONVERSIONDATA_DR; //1òí¨μàμêyY±£′úDR′÷à HAL_ADC_Init(&ADC1_Handler); //3êˉ HAL_ADCEx_Calibration_Start(&ADC1_Handler,ADC_CALIB_OFFSET,ADC_SINGLE_ENDED); //ADCD£× increase while adcx=Get_Adc_Average(ADC_CHANNEL_19,20);// temp=(float)adcx*(3.3/65536); // Compile and run See the figure below for wiring
This content was created by EEWORLD forum user star_66666. If you need to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the sourceOversamplingMode=DISABLE; //1y2éù1±
ADC1_Handler.Init.ConversionDataManagement=ADC_CONVERSIONDATA_DR; //1òí¨μàμêyY±£′úDR′÷à HAL_ADC_Init(&ADC1_Handler); //3êˉ HAL_ADCEx_Calibration_Start(&ADC1_Handler,ADC_CALIB_OFFSET,ADC_SINGLE_ENDED); //ADCD£× increase while adcx=Get_Adc_Average(ADC_CHANNEL_19,20);// temp=(float)adcx*(3.3/65536); // Compile and run See the figure below for wiring
This content was created by EEWORLD forum user star_66666. If you need to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source