bananasiong
New Member
Hi all,
I'm using PIC16F88 to drive a LCD text module. When no button is pressed within 30 seconds, the device will sleep and the LCD will be turned off. I use RB0/INT external interrupt to wake the device up and re-initialize the LCD.
I have no problem with the LCD and the counter part, I use timer 2 for counting the time.
This is the routine when no button is pressed in 30 seconds:
When the global interrupt is disabled, the device should wakeup from where it slept and continue executing the next instruction; when the global interrupt is enabled, the device should wakeup and go to the interrupt vector.
Before going to sleep, I've disabled the global interrupt, but the device sleep and wakeup immediately itself.
If I enable the global interrupt before the sleep instruction, everything works fine, wakeup when RB0 is pressed.
I use internal pullup and rise transition at RB0 for the interrupt.
I'm using PIC16F88 to drive a LCD text module. When no button is pressed within 30 seconds, the device will sleep and the LCD will be turned off. I use RB0/INT external interrupt to wake the device up and re-initialize the LCD.
I have no problem with the LCD and the counter part, I use timer 2 for counting the time.
This is the routine when no button is pressed in 30 seconds:
Code:
bcf INTCON, GIE ;disable global interrupt
bsf INTCON, INTE
call LCD_clr
bcf PORTB, 4 ;turn off LCD
sleep
nop
bcf INTCON, INTE
bsf PORTB, 4 ;turn on LCD
call Delay100
call LCD_Ini
bsf INTCON, GIE ;enable global interrupt
When the global interrupt is disabled, the device should wakeup from where it slept and continue executing the next instruction; when the global interrupt is enabled, the device should wakeup and go to the interrupt vector.
Before going to sleep, I've disabled the global interrupt, but the device sleep and wakeup immediately itself.
If I enable the global interrupt before the sleep instruction, everything works fine, wakeup when RB0 is pressed.
I use internal pullup and rise transition at RB0 for the interrupt.
Last edited: