- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
'buffer' is defined volatile, but its never accessed in the ISR. All other fields accessed by the ISR are not volatile.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Setting query and response to volatile should fix it (as hli said above)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hli: buffer is accessed in prepareResponse() function called in ISR.
Responselength = prepareResponse(); //copying bytes from buffer array to response array
e.pratt_1639216 : I tried making query and response to volatile, but with no success.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I write in buffer array in ISR, it works. But if I access buffer in main() and write into it, It wont reflect when I'm in ISR..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Basically, any variable you use in the ISR and use elsewhere you will need to declare as volatile to prevent the compiler from mixing up RAM reference locations. Hence why we suggested starting with that first.
Could the buffer variable be going out of scope somehow? (Probably not, just a thought)
Have you tried disabling the interrupts when writing to the Buffer array in main? The ISR could be firing mid-buffer write. (Atomicity issue)
Also, can you give an example of how you are writing to the buffer in main?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you create a simple project showing the problem (as simple as possible) and then share it here ('create workspace bundle')?