Variable accessible by ISR and Main code
Anonymous
Not applicable
Dec 19, 2008
12:00 AM
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Dec 19, 2008
12:00 AM
Question: How can a variable that can be accessed by both the idle loop ( in TD_Poll ) and also by a USB ISR be implemented such that, if it is being accessed by TD_Poll, ISR is not able to manipulate it until TD_Poll finishes and vice-versa.
Answer:
There are many different code styles which might accomplish this protection.
1.You could disable global interrupts (EA) for the protected area in TD_Poll and re-enable them afterward.You would not loose interrupts that arrive during that period, they would be queued during that period.
2.Another, you may decide not to clear the specific ISR until after the protected area in TD_Poll.It is best to keep use of ISRs to a minimum and make life a little more simple.
Rate this article:
Contributors
-
This widget could not be displayed.Anonymous