The interrupt on change is created by a matrix keyboard connected on portB (0-6).
I noticed that a short keypress allows PIC go to sleep, while a longer press keeps it semi awake.
Then I added this while-wend check just before pressed=0 in the main routine and now works OK:
Though not elegant nor explains why this happens, it kinda fixed the problem.Code:main: portb=$78 'set port to 01111000 txsta=0 'Turn off all peripherals rcsta=0 'before sleeping adcon0.0=0 'Disable ADC while pressed:pause 10:wend pressed=0 'reset flag pressed intcon.0=0 'reset RBIF flag t1con.0=0 'turn off timmer 1 buzzer=0 @ sleep @ nop
Ioannis




Bookmarks