use printf in isr,the cpu will restart

QbasicJacky
Posts: 10
Joined: Mon Apr 10, 2023 3:52 am

use printf in isr,the cpu will restart

Postby QbasicJacky » Thu Apr 27, 2023 5:42 am

how to use printf in isr savely

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

Re: use printf in isr,the cpu will restart

Postby mbratch » Thu Apr 27, 2023 9:58 pm

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.

ESP_Sprite
Posts: 9709
Joined: Thu Nov 26, 2015 4:08 am

Re: use printf in isr,the cpu will restart

Postby ESP_Sprite » Fri Apr 28, 2023 5:29 am

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.

Who is online

Users browsing this forum: No registered users and 77 guests