system_adc_read 读取错误的问题
-
- Posts: 20
- Joined: Fri Jul 24, 2015 3:00 pm
system_adc_read 读取错误的问题
Postby Lucifer3502 » Sat Dec 05, 2015 2:04 pm
使用RTOS_SDK_V1.0.4版本,每秒钟读取adc值,主要是用来读取热敏电阻的两端的电压值,根据电压来计算环境温度。
测试方法:
1. 在能连接路由器的情况下,每秒钟调用一次system_adc_read读取值,是正常的,长运暂时没有发现问题。
2. 在断开路由器的情况下,当模组长运很长一段时间后,(个人长运挂了8个多小时),每次调用system_adc_read接口,都返回1024,该值不会变化。模块断电重启后就恢复正常了。 测试很多次,都是这样的现象。
这是不是一个很严重的bug?
-
- Posts: 20
- Joined: Fri Jul 24, 2015 3:00 pm
-
- Posts: 20
- Joined: Fri Jul 24, 2015 3:00 pm
Re: system_adc_read 读取错误的问题
Postby Lucifer3502 » Thu Dec 10, 2015 4:16 pm
代码中就是在一个线程中的while循环中,加个一个子任务。这个子任务每一秒钟执行一次,子任务一开始就是读取adc的值。
unsigned int temp = 0;
unsigned short read_adc;
/*返回值单位:1/1024 V*/
read_adc = system_adc_read();
-
- Posts: 20
- Joined: Fri Jul 24, 2015 3:00 pm
Re: system_adc_read 读取错误的问题
Postby Lucifer3502 » Thu Dec 10, 2015 4:18 pm
-
- Posts: 20
- Joined: Fri Jul 24, 2015 3:00 pm
Re: system_adc_read 读取错误的问题
Postby Lucifer3502 » Sat Dec 12, 2015 8:02 am
#include "esp_common.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "lwip/sockets.h"
#include "lwip/dns.h"
#include "lwip/netdb.h"
#include "uart.h"
void ICACHE_FLASH_ATTR
adc_task(void *pvParameters)
{
while(1)
{
unsigned short read_adc;
/*返回值单位:1/1024 V*/
read_adc = system_adc_read();
printf("READ ADC: %d\r\n", read_adc);
vTaskDelay(1000 / portTICK_RATE_MS);
printf("TM:%u: SM:%u, WIFI STATE: %u\n", system_get_time(), system_get_free_heap_size(), wifi_station_get_connect_status());
}
}
/******************************************************************************
* FunctionName : user_init
* Description : entry of user application, init user function here
* Parameters : none
* Returns : none
*******************************************************************************/
void ICACHE_FLASH_ATTR
user_init(void)
{
uart_init_new();
printf("SDK version:%s\n", system_get_sdk_version());
/* need to set opmode before you set config */
wifi_set_opmode(STATION_MODE);
struct station_config *config = (struct station_config *)malloc(sizeof(struct station_config));
memset(config, 0, sizeof(struct station_config));
sprintf(config->ssid, "Netcore");
sprintf(config->password, "");
/* need to sure that you are in station mode first,
* otherwise it will be failed. */
wifi_station_set_config(config);
//wifi_station_set_auto_connect(1);
free(config);
xTaskCreate(adc_task, "adc_task", 256, NULL, 2, NULL);
}
出现问题的log如下:
reconnect
TM:1316648810: SM:56792, WIFI STATE: 3
READ ADC: 206
TM:1317648811: SM:56792, WIFI STATE: 3
READ ADC: 206
scandone
no Netcore found, reconnect after 1s
reconnect
TM:1318648816: SM:56792, WIFI STATE: 3
READ ADC: 206
TM:1319648810: SM:56792, WIFI STATE: 3
READ ADC: 1024
scandone
no Netcore found, reconnect after 1s
reconnect
TM:1320648811: SM:56792, WIFI STATE: 3
READ ADC: 1024
TM:1321648810: SM:56792, WIFI STATE: 3
READ ADC: 1024
-
- Posts: 20
- Joined: Fri Jul 24, 2015 3:00 pm
Re: system_adc_read 读取错误的问题
Postby Lucifer3502 » Fri Dec 18, 2015 9:06 am
不知道这个问题确认的怎么样了,问题是否存在,还是我的使用有问题?
如果确实有问题,那么你们是在下个版本sdk中修复还是发布一个补丁?
Re: system_adc_read 读取错误的问题
Postby ESP_Faye » Fri Dec 25, 2015 11:45 am
请参考如下使用
Code: Select all
portENTER_CRITICAL();
val=system_adc_read();
portEXIT_CRITICAL();
感谢您对 ESP8266 的关注!
Who is online
Users browsing this forum: No registered users and 2 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.