Skip to content

PRO TIP Block youtube.com at the DNS level — Pi-hole, NextDNS or your hosts file — but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

PIC MCU TUTORIALS #17 – Reentrancy & Volatile keyword (Interrupt traps) (Absolute Beginner)

3.1K views on YouTube

In this video, I’ll talk about the reentrancy problem and the “volatile” qualifier. These terms are related to issues caused by interrupts. These issues are more complicated than what I’ve talked about until now, but since I made videos about interrupts and recommended that you use them, I feel obligated to talk about them. I’ll also explain multiple concepts to help you understand these issues, and give you various solutions with examples to combat them…
___________________________
– XC8 Compiler User’s Guide:
http://ww1.microchip.com/downloads/en/devicedoc/50002053g.pdf

– Recursion example video:

___________________________
– Microcontroller used in the video: PIC18F46K22
– Programmer used in the video: PICKIT3
___________________________
– Why does my MPLABX IDE look different?:

___________________________
– Next video:

– Previous video:

___________________________
Timestamps:
[0:00] Start of the video
[1:01] What is reentrancy?
1:50 What is a reentrant function?
2:53 Why is reentrancy a problem?
[6:51] What is recursion?
8:04 Recursive vs Iterative functions
9:11 Why functions aren’t reentrant in your MCU, but are for computers?
9:30 Software stack explained
10:44 Using software stack with XC8 compiler in MPLAB
11:38 Configuring stack options
13:08 Configuring stack sizes
[14:55] Software stack example in MPLAB
[16:41] Using “__reentrant” & “__nonreentrant” specifiers
[18:27] Manually preventing reentrancy issue using “pragma”
[21:51] “Volatile” keyword
[27:08] Reentrancy but for variables
[32:30] End of the video