STM32未使用的变量错误

时间:2018-08-08 22:41:07

标签: stm32

对于STm32编程来说是很新的东西。

在运行代码时显示以下警告。 有人可以帮忙吗?

。\ Src \ main.c:在函数'ADC1_IF_Test'中: .. \ Src \ main.c:261:12:警告:变量'ADC1Volt'已设置但未使用[-Wunused-but-set-variable]       浮动ADC1Volt;             ^ ~~~~~~~~ .. \ Src \ main.c:260:62:警告:已设置变量'ADC1_13'但未使用[-Wunused-but-set-variable]   uint32_t ADC1_3,ADC1_5,ADC1_6,ADC1_8,ADC1_9,ADC1_10,ADC1_12,ADC1_13;                                                               ^ ~~~~~~ .. \ Src \ main.c:260:54:警告:已设置变量'ADC1_12'但未使用[-Wunused-but-set-variable]   uint32_t ADC1_3,ADC1_5,ADC1_6,ADC1_8,ADC1_9,ADC1_10,ADC1_12,ADC1_13;                                                       ^ ~~~~~~ .. \ Src \ main.c:260:46:警告:已设置变量'ADC1_10'但未使用[-Wunused-but-set-variable]   uint32_t ADC1_3,ADC1_5,ADC1_6,ADC1_8,ADC1_9,ADC1_10,ADC1_12,ADC1_13;                                               ^ ~~~~~~ .. \ Src \ main.c:260:39:警告:已设置变量'ADC1_9'但未使用[-Wunused-but-set-variable]   uint32_t ADC1_3,ADC1_5,ADC1_6,ADC1_8,ADC1_9,ADC1_10,ADC1_12,ADC1_13;                                        ^ ~~~~~ .. \ Src \ main.c:260:32:警告:已设置变量'ADC1_8'但未使用[-Wunused-but-set-variable]   uint32_t ADC1_3,ADC1_5,ADC1_6,ADC1_8,ADC1_9,ADC1_10,ADC1_12,ADC1_13;                                 ^ ~~~~~ .. \ Src \ main.c:260:25:警告:已设置变量'ADC1_6'但未使用[-Wunused-but-set-variable]   uint32_t ADC1_3,ADC1_5,ADC1_6,ADC1_8,ADC1_9,ADC1_10,ADC1_12,ADC1_13;                          ^ ~~~~~ .. \ Src \ main.c:260:18:警告:已设置变量'ADC1_5'但未使用[-Wunused-but-set-variable]   uint32_t ADC1_3,ADC1_5,ADC1_6,ADC1_8,ADC1_9,ADC1_10,ADC1_12,ADC1_13;                   ^ ~~~~~ .. \ Src \ main.c:在函数“ ADC3_IF_Test”中: .. \ Src \ main.c:317:34:警告:已设置变量'ADC3_8'但未使用[-Wunused-but-set-variable]   浮点型ADC3_9,ADC3_14,ADC3_15,ADC3_8;                                   ^ ~~~~~ .. \ Src \ main.c:317:25:警告:已设置变量'ADC3_15'但未使用[-Wunused-but-set-variable]   浮点型ADC3_9,ADC3_14,ADC3_15,ADC3_8;                          ^ ~~~~~~ .. \ Src \ main.c:317:16:警告:变量'ADC3_14'已设置但未使用[-Wunused-but-set-variable]   浮点型ADC3_9,ADC3_14,ADC3_15,ADC3_8;                 ^ ~~~~~~ .. \ Src \ main.c:317:8:警告:已设置变量'ADC3_9'但未使用[-Wunused-but-set-variable]   浮点ADC3_9,ADC3_14,ADC3_15,ADC3_8;

代码

无效ADC1_IF_Test(无效) {

uint32_t ADC1_3,ADC1_5,ADC1_6,ADC1_8,ADC1_9,ADC1_10,ADC1_12,ADC1_13;
 float ADC1Volt;
//Using Poll for COnversion for Testing;Shall use DMA method after it works!

HAL_ADC_Start(&hadc1);

// Reading ADC1 Channel 3
HAL_ADC_PollForConversion(&hadc1, 100);
ADC1_3 = (HAL_ADC_GetValue(&hadc1));
ADC1Volt =ADC1_3*0.80056;
HAL_Delay(100);

// Reading ADC1 Channel 5
HAL_ADC_PollForConversion(&hadc1, 100);
ADC1_5 = HAL_ADC_GetValue(&hadc1) * 0.80056;
HAL_Delay(100);

// Reading ADC1 Channel 5
HAL_ADC_PollForConversion(&hadc1, 100);
ADC1_6 = HAL_ADC_GetValue(&hadc1) * 0.80056;
HAL_Delay(100);

// Reading ADC1 Channel 6
HAL_ADC_PollForConversion(&hadc1, 100);
ADC1_6 = HAL_ADC_GetValue(&hadc1) * 0.80056;
HAL_Delay(100);

// Reading ADC1 Channel 8
HAL_ADC_PollForConversion(&hadc1, 100);
ADC1_8 = HAL_ADC_GetValue(&hadc1) * 0.80056;
HAL_Delay(100);

// Reading ADC1 Channel 9
HAL_ADC_PollForConversion(&hadc1, 100);
ADC1_9 = HAL_ADC_GetValue(&hadc1) * 0.80056;
HAL_Delay(100);

// Reading ADC1 Channel 10
HAL_ADC_PollForConversion(&hadc1, 100);
ADC1_10 = HAL_ADC_GetValue(&hadc1) * 0.80056;
HAL_Delay(100);

// Reading ADC1 Channel 12
HAL_ADC_PollForConversion(&hadc1, 100);
ADC1_12 = (HAL_ADC_GetValue(&hadc1) * 0.80056)/ADCPSMON_5V;
HAL_Delay(100);

// Reading ADC1 Channel 13
HAL_ADC_PollForConversion(&hadc1, 100);
ADC1_13 = (HAL_ADC_GetValue(&hadc1) * 0.80056)/ADCPSMON_24V;
HAL_Delay(100);

}

0 个答案:

没有答案