Hi Macgman2000,
I didn't analyze your code too closely, because frankly I am not smart enough to understand all the assembly code, and it compiled with too many errors here for me to sort out, so I did the next best thing, I tossed out the assembly interrupts and installed Darrel's DT_INTS, and recompiled. Please try it as you have the breadboard already set up. MPASM Required.
Code:
'http://www.picbasic.co.uk/forum/showthread.php?p=73542#post73542
'Macgman2000.bas
'********************************************************************
INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts
INCLUDE "Modedefs.Bas"
;@ device HS_OSC, LVP_OFF, WDT_OFF
; @ Device pic16F877A, HS_OSC, BOD_OFF, PWRT_ON, WDT_ON, PROTECT_OFF
@ __config _HS_OSC & _BODEN_OFF & _PWRTE_ON & _WDT_ON
DEFINE OSC 20
DEFINE DEBUGIN_REG PORTC ' Set portC as software RX in
DEFINE DEBUG_BAUD 2400 ' Set bit rate
DEFINE DEBUGIN_BIT 7 ' Set portC bit 7
DEFINE DEBUGIN_MODE 1 ' Set Debugin mode: 0 = true, 1 = inverted
;DEFINE INTHAND myint ' Setup interrupt handler button presses
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler RBC_INT, _keys2, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
; initialize Interrupts
OPTION_REG.6 = 1 ; option_reg RB0 interrupt rising=1, falling=0 edge
INTCON = %10010000 ; Enable INTE RB0 interrupt $90
;set ports to input
TRISD = %11111111 ; 8 button press inputs + RB0 interrupt for all off
;set ports to output
TRISA = %00000000 ; set port A to outputs for relays
TRISE = %00000000 ; set port E to outputs for relays
;set port initializations
PORTA = %00000000
PORTE = %00000000
' Configure internal registers
payload VAR byte bank0 system ' data location for selecting relays
payload1 var byte bank0 system ' previous good data
chksum var byte bank0 system ' check sum calculated at the TX side and sent over RF link
payload = 0
goto mainloop
keys2: ; called by interrupt to update relay
if payload = 0 then
portE = 0
portA = 0
endif
if payload = 1 then
toggle portA.0
endif
if payload = 2 then
toggle portA.1
endif
if payload = 4 then
toggle portA.2
endif
if payload = 8 then
toggle portA.3
endif
if payload = 16 then
toggle portA.4
endif
if payload = 32 then
toggle portA.5
endif
if payload = 64 then
toggle portE.0
endif
if payload = 128 then
toggle portE.1
endif
@ INT_RETURN
mainloop:
INTCON = %10010000 ; Enable INTE RB0 interrupt $90
; receive data packets and check sum, throwing out sync byte (255)
debugin [wait (255),payload,chksum]
if chksum != payload then ; verify good packets by comparing check sums
goto mainloop ; check sum does not match transmitted data
endif
update_keys:
if payload = 0 then
portE = 0
portA = 0
endif
if payload = 1 then
toggle portA.0
endif
if payload = 2 then
toggle portA.1
endif
if payload = 4 then
toggle portA.2
endif
if payload = 8 then
toggle portA.3
endif
if payload = 16 then
toggle portA.4
endif
if payload = 32 then
toggle portA.5
endif
if payload = 64 then
toggle portE.0
endif
if payload = 128 then
toggle portE.1
endif
goto mainloop
Bookmarks