Hallo, ich versuche mit einen STM32f373 intern die Temperatur zu ermitteln. Soweit funktioniert das einigermaßen, jedoch bekomme ich häufig ein Temperaturoffset nach einen Reset und messe 34 anstelle von 24 °C. Könnt ihr mir weiterhelfen? Hier der Code für die Initialisierung:
1 | RCC_ADCCLKConfig(RCC_PCLK2_Div8); |
2 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); |
3 | ADC_TempSensorVrefintCmd(ENABLE); |
4 | |
5 | breakt(1); |
6 | |
7 | ADC_InitTypeDef ADC_InitStructure; |
8 | ADC_InitStructure.ADC_ContinuousConvMode = DISABLE; |
9 | ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; |
10 | ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; |
11 | ADC_InitStructure.ADC_NbrOfChannel = 1; |
12 | ADC_InitStructure.ADC_ScanConvMode = DISABLE; |
13 | ADC_Init(ADC1,&ADC_InitStructure); |
14 | |
15 | NVIC_InitTypeDef NVIC_adc; |
16 | NVIC_adc.NVIC_IRQChannel = ADC1_IRQn; |
17 | NVIC_adc.NVIC_IRQChannelCmd = ENABLE; |
18 | NVIC_adc.NVIC_IRQChannelPreemptionPriority = 0x0F; |
19 | NVIC_adc.NVIC_IRQChannelSubPriority = 0x01; |
20 | NVIC_Init(&NVIC_adc); |
21 | |
22 | ADC_RegularChannelConfig(ADC1, ADC_Channel_Vrefint, 1, ADC_SampleTime_239Cycles5); |
23 | ADC_Cmd(ADC1, ENABLE); |
24 | ADC_ITConfig(ADC1, ADC_IT_EOC, ENABLE); |
25 | |
26 | // Enable ADC1 reset calibration register
|
27 | ADC_ResetCalibration(ADC1); |
28 | // Check the end of ADC1 reset calibration register
|
29 | while(ADC_GetResetCalibrationStatus(ADC1)); |
30 | |
31 | // Start ADC1 calibration
|
32 | ADC_StartCalibration(ADC1); |
33 | // Check the end of ADC1 calibration
|
34 | while(ADC_GetCalibrationStatus(ADC1)); |