station模式下开启一个pin中断(该中断用于处理一个433Mhz无线接收模块,中断很频繁 都是us级的),这时候8266模块会一直重启,如果开始station+ap模式就不会重启,可是现在产品开发需求必须工作在station模式。
如下为重启打印信息:
pm open,type:2 0
Fatal exception 0(IllegalInstructionCause):
epc1=0x40244a48, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
在eagle.s里面找到40244a48对应的是:
excw40244a48 <Pin_Interrupt>:void ICACHE_FLASH_ATTR Pin_Interrupt(void *arg){unsigned int gpio_status;
请问要怎么解决这个问题啊?
如下为代码
#include "gpio.h"
#include "driver/uart.h"
#include "user_main.h"
ETSTimer connect_timer;
void ICACHE_FLASH_ATTR Wifi_conned(void *arg)
{
static uint8 count=0;//计数检测连接正常与否的次数
uint8 status;
os_timer_disarm(&connect_timer);
count++;
status=wifi_station_get_connect_status();//获取当前连接状态
if(status==STATION_GOT_IP)//当前已经获取到路由器分配的IP 则表示成功连接路由器
{
count=0;//检测计数器清0
os_printf("Router connect success!");
ETS_GPIO_INTR_ENABLE() ;//开启GPIO电平变化中断
return;
}
else
{
if(count>=7)//重复连接7次之后 提示连接失败 并且停止连接
{
count=0;//检测连接状态计数器置0
wifi_station_disconnect();//关闭station模式的连接操作 否则每1s回去重连一次到时ap模式的连接不稳定
ETS_GPIO_INTR_ENABLE() ;//开启GPIO电平变化中断
return;
}
}
os_timer_arm(&connect_timer,2000,NULL);//每2秒重新连接一次
}
void ICACHE_FLASH_ATTR scan_done(void *arg,STATUS status)
{
struct station_config stationConf;
if (status == OK)
{
wifi_station_get_config(&stationConf);//获取station模式下的默认参数
os_memcpy(&stationConf.ssid, "ChinaNet-99base", 32);
os_memcpy(&stationConf.password, "xm99base", 64);
wifi_station_set_config_current(&stationConf);
wifi_station_connect();//开启station连接
os_timer_setfn(&connect_timer,Wifi_conned,NULL);//开一个2s的定时器 用于检测station连接路由器是否成功
os_timer_arm(&connect_timer,2000,NULL);
}
}
void to_scan(void)
{
wifi_station_scan(NULL,scan_done);
}
void ICACHE_FLASH_ATTR Pin_Interrupt(void *arg)
{
unsigned int gpio_status;
gpio_status=GPIO_REG_READ(GPIO_STATUS_ADDRESS); //锟斤拷取状态
ETS_GPIO_INTR_DISABLE(); //锟截憋拷锟叫讹拷
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS,gpio_status);
ETS_GPIO_INTR_ENABLE() ;
}
void user_init(void)
{
uint8 opmode;
uart_init(115200,115200);
os_printf("\r\nwifidoor version:%s\n", system_get_sdk_version());
wifi_set_opmode(STATION_MODE);//设置wifi工作模式 -->AP模式
system_init_done_cb(to_scan);//注册系统初始化完成的回调函数
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U,FUNC_GPIO4);//RF信号输入IO初始化
GPIO_DIS_OUTPUT(GPIO_ID_PIN(4)); // 设置成输入
gpio_pin_intr_state_set(GPIO_ID_PIN(4),GPIO_PIN_INTR_ANYEDGE);//设置中断类型:边沿中断
ETS_GPIO_INTR_ATTACH(Pin_Interrupt,NULL);//定义中断函数
}
void user_rf_pre_init(void)
{
}
NONOS 1.5.3 SDK station模式下开启Pin中断 重启问题
Re: NONOS 1.5.3 SDK station模式下开启Pin中断 重启问题
Postby ESP_Alen » Fri Oct 14, 2016 10:50 am
huangxq wrote:station模式下开启一个pin中断(该中断用于处理一个433Mhz无线接收模块,中断很频繁 都是us级的),这时候8266模块会一直重启,如果开始station+ap模式就不会重启,可是现在产品开发需求必须工作在station模式。
如下为重启打印信息:
pm open,type:2 0
Fatal exception 0(IllegalInstructionCause):
epc1=0x40244a48, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
在eagle.s里面找到40244a48对应的是:
excw40244a48 <Pin_Interrupt>:void ICACHE_FLASH_ATTR Pin_Interrupt(void *arg){unsigned int gpio_status;
请问要怎么解决这个问题啊?
如下为代码
#include "gpio.h"
#include "driver/uart.h"
#include "user_main.h"
ETSTimer connect_timer;
void ICACHE_FLASH_ATTR Wifi_conned(void *arg)
{
static uint8 count=0;//计数检测连接正常与否的次数
uint8 status;
os_timer_disarm(&connect_timer);
count++;
status=wifi_station_get_connect_status();//获取当前连接状态
if(status==STATION_GOT_IP)//当前已经获取到路由器分配的IP 则表示成功连接路由器
{
count=0;//检测计数器清0
os_printf("Router connect success!");
ETS_GPIO_INTR_ENABLE() ;//开启GPIO电平变化中断
return;
}
else
{
if(count>=7)//重复连接7次之后 提示连接失败 并且停止连接
{
count=0;//检测连接状态计数器置0
wifi_station_disconnect();//关闭station模式的连接操作 否则每1s回去重连一次到时ap模式的连接不稳定
ETS_GPIO_INTR_ENABLE() ;//开启GPIO电平变化中断
return;
}
}
os_timer_arm(&connect_timer,2000,NULL);//每2秒重新连接一次
}
void ICACHE_FLASH_ATTR scan_done(void *arg,STATUS status)
{
struct station_config stationConf;
if (status == OK)
{
wifi_station_get_config(&stationConf);//获取station模式下的默认参数
os_memcpy(&stationConf.ssid, "ChinaNet-99base", 32);
os_memcpy(&stationConf.password, "xm99base", 64);
wifi_station_set_config_current(&stationConf);
wifi_station_connect();//开启station连接
os_timer_setfn(&connect_timer,Wifi_conned,NULL);//开一个2s的定时器 用于检测station连接路由器是否成功
os_timer_arm(&connect_timer,2000,NULL);
}
}
void to_scan(void)
{
wifi_station_scan(NULL,scan_done);
}
void ICACHE_FLASH_ATTR Pin_Interrupt(void *arg)
{
unsigned int gpio_status;
gpio_status=GPIO_REG_READ(GPIO_STATUS_ADDRESS); //锟斤拷取状态
ETS_GPIO_INTR_DISABLE(); //锟截憋拷锟叫讹拷
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS,gpio_status);
ETS_GPIO_INTR_ENABLE() ;
}
void user_init(void)
{
uint8 opmode;
uart_init(115200,115200);
os_printf("\r\nwifidoor version:%s\n", system_get_sdk_version());
wifi_set_opmode(STATION_MODE);//设置wifi工作模式 -->AP模式
system_init_done_cb(to_scan);//注册系统初始化完成的回调函数
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U,FUNC_GPIO4);//RF信号输入IO初始化
GPIO_DIS_OUTPUT(GPIO_ID_PIN(4)); // 设置成输入
gpio_pin_intr_state_set(GPIO_ID_PIN(4),GPIO_PIN_INTR_ANYEDGE);//设置中断类型:边沿中断
ETS_GPIO_INTR_ATTACH(Pin_Interrupt,NULL);//定义中断函数
}
void user_rf_pre_init(void)
{
}
Please remove the ICACHE_FLASH_ATTR attribution of Pin_Interrupt.
the interrupt routine and function called by interrupt routine should not have the attribution of ICACHE_FLASH_ATTR.
Re: NONOS 1.5.3 SDK station模式下开启Pin中断 重启问题
Postby ESP_Alen » Tue Oct 18, 2016 3:50 pm
huangxq wrote:谢谢!问题解决了
Welcome.
Who is online
Users browsing this forum: No registered users and 59 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.