2017-07-21 03:01 AM
Following the previous post:
https://community.st.com/0D50X00009XkYamSAF
I tried to debug my program.The program has two steps.
1- Setting PA1, PA2 and PA3 as GPIO and reading ADC_CHANNEL_0
Waiting...
2-
Setting
PA0, PA1 and PA3 as GPIO
and reading ADC_CHANNEL_2.Waiting...
To select the ADC channel 0, we should set the following register to 0x1:
ADC1->CHSELR = ADC_CHSELR_CHSEL0; // or = 0x1;
To select the ADC channel 2, we should set the following register to 0x4:
ADC1->CHSELR = ADC_CHSELR_CHSEL4; // or = 0x4;
When I watch this register in debug mode, its value is set correctly in the first step. But in the second step its value is set to 5. (Actually the first bit does not reset.).
I also used the HAL libraries. HAL_ADC_ConfigChannel(&hadc, &sConfig) routine works fine individually. (I mean running only one step at once.) But running two steps consequently, rises the same problem.
I don't know what is the problem.
#channel #adc #chselr