I've been trying to set up a simple interrupt to toggle my display on and off. I'm running a 28x2 and set up the following code to initialize the interrupt. The interrupt should be generated by a button push which will drive the appropriate pins (B.0 and B.1) to logic 1. Although A.3 is in the code, it is not used at the moment.
I must be missing something really obvious because the program totally ignores any button push. I have the pins connected to a 10k pulldown and have checked that the buttons generate the positive rail condition (in this case 3.26v).
Day_Mode:
setint OR %00000011,%00000011,B
do .......
My interrupt sub is as follows
interrupt:
pause 100 ;debounce
;b_next = pinB.0, b_display = pinA.3, b_menu = pinB.1
if b_next = 1 or b_display = 1 or b_menu = 1 then interrupt
sertxd("int",cr)
hi2csetup I2Cmaster, OLED_ADDR, i2cfast_8, i2cbyte
ptr = sp_display_state
if @ptr = 1 then
@ptr = 0
hi2cout (Disp_cmd, DISPLAYOFF)
else
@ptr = 1
hi2cout (Disp_cmd, DISPLAYON)
endif
ptr = sp_base_mode
read ee_base_status, @ptr
setint OR %00000011,%00000011,B
if @ptr > 0 then
goto day_mode
else
goto night_mode
endif
return
Pointing out my lack of mental capacity would be much appreciated. Derogatory statements may be added for bonus points.
I must be missing something really obvious because the program totally ignores any button push. I have the pins connected to a 10k pulldown and have checked that the buttons generate the positive rail condition (in this case 3.26v).
Day_Mode:
setint OR %00000011,%00000011,B
do .......
My interrupt sub is as follows
interrupt:
pause 100 ;debounce
;b_next = pinB.0, b_display = pinA.3, b_menu = pinB.1
if b_next = 1 or b_display = 1 or b_menu = 1 then interrupt
sertxd("int",cr)
hi2csetup I2Cmaster, OLED_ADDR, i2cfast_8, i2cbyte
ptr = sp_display_state
if @ptr = 1 then
@ptr = 0
hi2cout (Disp_cmd, DISPLAYOFF)
else
@ptr = 1
hi2cout (Disp_cmd, DISPLAYON)
endif
ptr = sp_base_mode
read ee_base_status, @ptr
setint OR %00000011,%00000011,B
if @ptr > 0 then
goto day_mode
else
goto night_mode
endif
return
Pointing out my lack of mental capacity would be much appreciated. Derogatory statements may be added for bonus points.