Page 1 of 1
use printf in isr,the cpu will restart
Posted: Thu Apr 27, 2023 5:42 am
by QbasicJacky
how to use printf in isr savely
Re: use printf in isr,the cpu will restart
Posted: Thu Apr 27, 2023 9:58 pm
by mbratch
There are two main problems with using printf in an ISR: amount of stack consumed, and amount of processing time taken. ISRs usually have a limited amount of stack space allocated, and usually have limited time to perform its task.
You can usually configure your ISR stack space to be larger and that might enable you to use printf. If the real time for printf is the issue, then you'll need to use a simpler, faster means of printing without general formatting libraries. Using simpler methods for printing will also help solve the stack size issue.
Re: use printf in isr,the cpu will restart
Posted: Fri Apr 28, 2023 5:29 am
by ESP_Sprite
Also, printf is a blocking function. You can't use blocking functions in an isr. Either use esp_rom_printf/ets_printf or ESP_LOG_EARLY.