I need to have data synchronization in my code. Currently I am accessing a global value inside interrupt and also in a local function which may corrupt the data if interrup
It's probably as simple as this in your main code:
disable_interrupts(); value += 1; enable_interrupts();
So you make sure the interrupt cannot fire while you're using the value in the main code.