Commit Graph

8 Commits

Author SHA1 Message Date
Abhijit Kshirsagar Kshirsagar 85a2491634 Quick Aside to debug GPIO ISRs
Problem: It is seen that the GPIO ISR was getting called more than once
for every button press.

Diagnosis:

The last instruction in the GPIO Interrupt handler is a write to the ICR
register which clears the interrupt. However, this write takes multiple
cycles, depending on the caching involved. As a result, after the
instruction to write to ICR, the microcontroller exits from the ISR
function but the write has not yet completed. The controller sees this
as a pending interrupt and goes into the ISR again. However, by the time
the controller enters the ISR this second time the ICR write has indeed
happened, and it appears to be a spurious interrupt call.

If the code is run in single-step debug mode, it gives the code enough
time to write to the ICR register and therefore the ISR is not called a
second time.

Solution:

Wait for a few cycles *after* the ICR write instruction and before
exiting from the ISR. The official documentation recommends a DSB
instruction but that may not be enough to account for vendor-specific
write-caching. In such a case a simple write to a register location
should be enough.

Additional Info:
https://developer.arm.com/documentation/ka003795/latest/
2023-09-04 17:49:23 +05:30
Abhijit Kshirsagar Kshirsagar dd679556d5 Add GPIO Interrupt Code 2023-09-04 10:37:29 +05:30
Abhijit Kshirsagar Kshirsagar 169e06990e Systick Interrupt Code 2023-09-01 20:20:00 +05:30
Abhijit Kshirsagar Kshirsagar 211c555186 Systick Basic Example 2023-09-01 20:01:51 +05:30
Abhijit Kshirsagar Kshirsagar 416f5f1d81 Refactor PORTF Init Code into function 2023-09-01 20:00:30 +05:30
Abhijit Kshirsagar Kshirsagar 786dc7f5c5 Add Ancillary Files 2023-09-01 17:33:47 +05:30
Abhijit Kshirsagar Kshirsagar c8a891b513 Add base code 2023-09-01 17:32:58 +05:30
Abhijit Kshirsagar Kshirsagar 92a2716ca6 Add .gitignore 2023-09-01 17:28:50 +05:30