-
I am using arduino mega, and arduino 1.8.8. Code is compied using O3 optimization. I have changes Os to O3 in platform.txt at 3 places for fast code.
-
I have foloowing features enabled in arduino:
a) code send data serial through usb port available on mega i.e. Serial0 at 9600 baud rate and also used to burn code via arduino software
b) code reads data serially through a device, only rx pin is used, tx not connected. Serial2 at 2400 baud rate
c) Lcd 20x4. : standard arduino library
d) I2C based rtc ds1307 : GitHub - PaulStoffregen/DS1307RTC: Use a DS1307 Real Time Clock chip with the Time library
e) Internal eeprom to read & store data
f) serial port used to trasmit data , only tx is used, rx unconnected. Serial3 at 9600 baud.
g) Timer 3 at period interrupt of 20ms to scan 4 keys connected at pins.
h) A ps2 keyboard : PS2Keyboard Library, Connect a keyboard for user input -
Problem is when i start the code, i read nothing from PS2 keyboard even if I press the keys on ps2 keyboard. If I keep on pressing some ps2 keyboard for around 10sec, then keyboard start working fine.
-
If i disable everything in code except ps2 library, then code works fine.
-
in complete code, i dont see anywhere i disable keyboard lib.
-
what i suspect, is that i have too many serial interrupt on rx pin, that may be causing issue, as it may interrupt the ps2 code. I dont read serial interrupt actually, as I read on sequentially in mainloop code. where to disable serial interrupt?
-
if not, what else could be issue
Please post your full sketch. If possible, you should always post code directly in the forum thread as text using code tags (</> button on the toolbar). This will make it easy for anyone to look at it, which will increase the likelihood of you getting help. If the sketch is longer than the forum will allow then it's OK to add it as an attachment. After clicking the "Reply" button, you will see an "Attachments and other settings" link.
Please always do an Auto Format (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor) on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read.
I realised, it works fine in below case:
-
When i power up system, without connecting PS2 keyboard, and then connect PS2 keyboard i,e after power up, then it works, all three led on keyboard blinks and it works fine.
-
Whereas when i power up the system with ps2 keyboard connceted, then keyboard dont work. If then i keep pressing some key, after sometime all three led blink & then keyboard works. But i have to press key for more than 15-20sec