Hello~
I have a qeustion.
In the example code "telink mesh _ sdk",
In the "light.h" file within the "light8258" project,
I have verified that if "ADC_SET_CHN_ENABLE" is set to 1, the ADC value of GPIO_PB4 is programmed to be read.
But I want to read other ports besides that.
Which part should I modify to read simultaneously or sequentially?
Is it possible to read only one port at a time on the 8258?
As a simple example, if I have to read the AD values of "PB0" and "PB1", can I process them in the main loop as shown below?
I wonder if the code below is the right way.
main()
{
adc_init();
adc_base_init(GPIO_PB0);
adc_power_on_sar_adc(1);
base_PB0_Ad_val = adc_sample_and_get_result();
adc_init();
adc_base_init(GPIO_PB1);
adc_power_on_sar_adc(1);
base_PB0_Ad_val = adc_sample_and_get_result();
}
No related topics |
Hi,
it can read only one port at a time,
just for reference.
u8 flag =0;
adc_init();
adc_base_init(GPIO_PB1);
adc_power_on_sar_adc(1);
loop()
{
if( flag ==0)
{
base_PB1_Ad_val = adc_sample_and_get_result();
adc_power_on_sar_adc(0);//stop adc
adc_base_init(GPIO_PB0);
adc_power_on_sar_adc(1);//start adc
flag =1;
}
else
{
base_PB0_Ad_val = adc_sample_and_get_result();
adc_power_on_sar_adc(0);//stop adc
adc_base_init(GPIO_PB1);
adc_power_on_sar_adc(1);
flag = 0
}
}
thank you. soyo