[Solved] Hardware timer crashes, nonos SDK 1.5.2

Goldpin
Posts: 2
Joined: Mon Mar 28, 2016 2:55 am

[Solved] Hardware timer crashes, nonos SDK 1.5.2

Postby Goldpin » Mon Mar 28, 2016 3:14 am

Hi,

I'm using hw_timer.c from nonos SDK 1.5.2 to set a hardware timer without autoload. The callback function fires with specified delays, but i'm getting frequent crashes (every approx 5 sec). Crashes stops when I'm not using hardware timer.

Here is the crash:

Code: Select all

state: 5 -> 2 (2c0)
rm 0
reconnect
state: 2 -> 0 (0)
f r0, scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2
cnt

connected with TP-LINK 3, channel 4
dhcp client start...
ip:192.168.1.104,mask:255.255.255.0,gw:192.168.1.1
pm open,type:2 0
Fatal exception 0(IllegalInstructionCause):
epc1=0x40244cf8, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000

 ets Jan  8 2013,rst cause:1, boot mode:(3,0)

load 0x40100000, len 29608, room 16
tail 8
chksum 0xf6
load 0x3ffe8000, len 884, room 0
tail 4
chksum 0x08
load 0x3ffe8380, len 784, room 4
tail 12
chksum 0xf3
csum 0xf3
r��l��ĞeStepper motor  init succesful
espconn_accept [0] !!!
mode : sta(18:fe:34:9b:96:fb)
add if0
f r-1, scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2


Here is the initialization code:

Code: Select all

hw_timer_init(FRC1_SOURCE,0);
hw_timer_set_func(stepper_timer_cb);
hw_timer_arm(2500);


Here is the callback function:

Code: Select all

static void ICACHE_FLASH_ATTR stepper_timer_cb(void)
{
    if(!GPIO_INPUT_GET(step_pin)) gpio_output_set((1<<step_pin),0,0,0);
    else gpio_output_set(0,(1<<step_pin),0,0);
    hw_timer_arm(2500);
}


I also noticed that when the timer is not armed, the callback function still fires, approx every 0.5s. Looks like something else is triggering the interrupt.

Any help would be appreciated.

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: Hardware timer crashes, nonos SDK 1.5.2

Postby ESP_Faye » Wed Mar 30, 2016 9:59 am

Hi,

Please delete the "ICACHE_FLASH_ATTR " before your hardware timer callback. The interrupt handler should not be stored in flash.
static void stepper_timer_cb(void)
{
...
}


Please have a try with the attachment, if your problem is still unsolved, please feel free to let us know.
Attachments
hw_timer_for_ESP8266_NONOS_SDK_V1.5.2.zip
(1.95 KiB) Downloaded 418 times

Goldpin
Posts: 2
Joined: Mon Mar 28, 2016 2:55 am

Re: Hardware timer crashes, nonos SDK 1.5.2

Postby Goldpin » Thu Mar 31, 2016 3:23 am

Thanks a lot, it works now.

I deleted the "ICACHE_FLASH_ATTR", but this wasn't enough. But after replacing "hw_timer.c" from SDK with the file you provided it works perfectly!

Who is online

Users browsing this forum: No registered users and 14 guests