Forum Discussion
Altera_Forum
Honored Contributor
20 years agoHow to use interrupt?
Hello. I want to use interrupt from USER_PIO, but I don't know how to use. I tried this sample code , but it seems that ISR is not executed. (I modified two point. *definition of...
Altera_Forum
Honored Contributor
20 years agoi think you can not use printf in ISR.
Restricted Environment ISRs run in a restricted environment. A large number of the HAL API calls are not available from ISRs. For example, accesses to the HAL file system are not permitted. As a general rule, when writing your own ISR, never include function calls that can block waiting for an interrupt. In addition, you should be careful when calling ANSI C standard library functions inside of an ISR. No calls should be made using the C standard library I/O API, because calling these functions can result in deadlock within the system, i.e., the system can become permanently blocked within the ISR. In particular, you should not call printf() from within an ISR without careful consideration. If stdout is mapped to a device driver that uses interrupts for proper operation, the printf() call can deadlock the system waiting for an interrupt that never occurs because interrupts are disabled. You can use printf() from within ISRs safely, but only if the device driver does not use interrupts..