'buffer' is defined volatile, but its never accessed in the ISR. All other fields accessed by the ISR are not volatile.
Setting query and response to volatile should fix it (as hli said above)
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.
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..
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?
Can you create a simple project showing the problem (as simple as possible) and then share it here ('create workspace bundle')?