- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the reference the return value is void, but how about I want to allocate a new variable in ISR and access it later in the main function?
Thanks!Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use global variable which can be accessed in any function as well as in ISR routine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- You can use global variable which can be accessed in any function as well as in ISR routine. --- Quote End --- However in my case, the variable is allocated dynamically, the size of the variable is unknown until ISR is triggered. Can I declare the global variable and then define its memory allocation later on?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You'd need a memory allocator that is callable from an ISR.
Whether one exists depends on the operating system code you are running. It is unlikely that the malloc() in the BSP library is callable from ISRs. Maybe you can use a fixed size memory block as a software fifo.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page