NONOS 1.5.3 SDK station模式下开启Pin中断 重启问题

huangxq
Posts: 5
Joined: Fri Oct 14, 2016 10:08 am

NONOS 1.5.3 SDK station模式下开启Pin中断 重启问题

Postby huangxq » Fri Oct 14, 2016 10:21 am

station模式下开启一个引脚电平变化中断(这个中断用于接收433Mhz模块的信号 中断非常频繁),会导致wifi模块一直重启 但是设置成station+ap模式就不会重启了。
重启信息:
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)
{
}

ESP_Xutao
Posts: 134
Joined: Tue Sep 27, 2016 5:42 pm

Re: NONOS 1.5.3 SDK station模式下开启Pin中断 重启问题

Postby ESP_Xutao » Fri Dec 02, 2016 4:29 pm

你好
你这也可能是连路由时的干扰,你可以将wifi模式改为none试一下。

Who is online

Users browsing this forum: No registered users and 58 guests