Interrupts and sdk func
Interrupts and sdk func
Postby SpenZerX » Thu Oct 08, 2015 2:22 am
is it allowed to use sdk functions (os_malloc, strcpy) in interrupts (GPIO)?
Can subroutines called from interrupt get ICACHE_FLASH_ATTR?
Or may this be the cause of random watchdog resets?
Re: Interrupts and sdk func
Postby dkinzer » Thu Oct 08, 2015 3:34 am
In an ISR, it is not allowed to call a function, either directly or indirectly, that resides in .irom0.text. If you are unsure where a function is located, consult the .sym file (which can be generated from the .elf file by "xtensa-lx106-elf-gcc-nm -n").SpenZerX wrote:is it allowed to use sdk functions (os_malloc, strcpy) in interrupts (GPIO)?
Beaverton, OR, USA
Re: Interrupts and sdk func
Postby SpenZerX » Thu Oct 08, 2015 4:07 am
(Without stopping main task with polling)
Set up a poll timer (1 millisecound timer) , which can use SDK-Functions?
Re: Interrupts and sdk func
Postby joostn » Thu Oct 08, 2015 3:35 pm
system_os_task(..);
In your interrupt handler, say it's an UART RX interrupt:
store the received data in a buffer and signal the task queue by calling:
system_os_post(..);
system_os_post will cause the task handler you registered in system_os_task to be called 'very soon', but outside the interrupt context. In the task handler you do any lengthy processing. While your task handler is running, new interrupts may occur. The interrupt handler should be kept as short as possible. Even if it would be safe to call malloc, doing this in a ISR is bad practise. Instead pre-allocate the necessary buffer space in your user_init.
In a well designed system polling is never necessary.
Re: Interrupts and sdk func
Postby SpenZerX » Thu Oct 08, 2015 8:54 pm
But it is an SDK Function that may be also cached from rom. I will give it a try.
Re: Interrupts and sdk func
Postby dkinzer » Thu Oct 08, 2015 11:13 pm
It isn't. And, by the way, it isn't necessary to just blindly try something. As I mentioned you can generate a .sym file and confirm with certainty whether a particular function (SDK or otherwise) is in .irom0.text. The .sym file excerpt below, from one of my applications, clearly shows that system_os_post is not in .irom0.text. Any function listed between _irom0_text_start and _irom0_text_end is cached. If a function is listed elsewhere, it isn't cached.SpenZerX wrote:But it is an SDK Function that may be also cached from rom. I will give it a try.
Code: Select all
...
40100220 T pvPortMalloc
401008f0 T system_get_time
4010090c T system_os_post
...
40211000 A _irom0_text_start
40211008 T post_init
40211034 T zb_mainTaskAddr
40211034 T zf_Main
...
4023b70c A _irom0_text_end
Beaverton, OR, USA
Re: Interrupts and sdk func
Postby eriksl » Mon Oct 12, 2015 1:04 am
Re: Interrupts and sdk func
Postby joostn » Mon Oct 12, 2015 3:34 am
Who is online
Users browsing this forum: No registered users and 27 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.