1. I am using arduino mega 2560. Connected are 20 segments together, refreshed every 500us. After every 500us, one segment is enable & written.
2. Also a PS2 keyboard is connected to read keys & display on segment. Library used is PS2Keyboard.cpp - PS2Keyboard library Written by Christian Weichel <firstname.lastname@example.org>
3. Ps2 & timer refreshing code of 20 segments works independently correctly. Problem arises when I merge both codes together. In that case what happens is I am not able to read correctly from keyboard. Probably due to when timer interrupt comes, it blocks rest of interrupt until it is processed.
4. Timer 2 is used and for PS2 data line is pin 19 & clock pin is 18.
5. Now how to resolve this issues. Refreshing leds is also important other flickering is observed.
6. I read "http://www.gammon.com.au/interrupts", & read that inside interrupt function, below function can be used to enable interrupt again.
interrupts (); // allow more interrupts
7. this way code is working, but i am not sure how safe it is use.
in top of timer2 isr I have written: