Skip to content

Commit 0850553

Browse files
canchebagurTaddyHC
andauthored
Update content/hardware/03.nano/boards/nano-r4/tutorials/04.external-interrupts/content.md
Co-authored-by: TaddyHC <[email protected]>
1 parent c1378ef commit 0850553

File tree

1 file changed

+2
-1
lines changed
  • content/hardware/03.nano/boards/nano-r4/tutorials/04.external-interrupts

1 file changed

+2
-1
lines changed

content/hardware/03.nano/boards/nano-r4/tutorials/04.external-interrupts/content.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,8 @@ This example demonstrates several key concepts when working with multiple interr
392392
Writing effective Interrupt Service Routines requires discipline. These guidelines will help you avoid the most common pitfalls:
393393

394394
- **Keep ISRs extremely short**. Your ISR should execute in microseconds, not milliseconds. The golden rule is to do the absolute minimum work necessary (typically just setting a flag or incrementing a counter). Complex operations belong in your main loop where they do not block other interrupts.
395-
- **Always use `volatile` for shared variables**. Any variable modified in an ISR and read in your main code (or vice versa) must be declared `volatile`. This prevents the compiler from caching the variable in a register where changes are not be visible between the ISR and main code.
395+
- **Always use `volatile` for shared variables**. Any variable modified in an ISR and read in your main code (or vice versa) must be declared `volatile`. This prevents the compiler from caching the variable in a register where changes would not be visible between the ISR and main code.
396+
396397
- **Never call blocking functions**: Functions like `delay()`, `Serial.print()`, `millis()`, or anything that waits for hardware are forbidden in ISRs. These functions often rely on interrupts themselves and calling them from an ISR can cause deadlocks or crashes.
397398
- **Protect multi-byte shared data**. When your main code needs to read a multi-byte variable that an ISR modifies (like `long` or `float`), you must temporarily disable interrupts to prevent the value from changing mid-read.
398399

0 commit comments

Comments
 (0)