Hello,
Can someone help me please. (sorry but my english is not very good I'm Spanish)
I am trying to modify a program that is on the net. It's a program to recive DMX.
What I am trying to do, is to be able to change the DMX channel with a remote control, but the program does not recognize a variable and I can't find the problem.
I am using Picbasic 2.46 and I am mixing basic with assembly.
The circuit has two PICs. The first PIC receives the signal from the IR remote control and sends the information decoded to the next PIC via RS 232. The information received
on this PIC is correct, but when I put the variable in the program it doesn't work.
I have tried defining the variable in basic and in asm but none of them work.
Here is an example in basic:
But even if I do it in assembly it doesn't work
Here is the complete program:
Thank you very much for the help.
Can someone help me please. (sorry but my english is not very good I'm Spanish)
I am trying to modify a program that is on the net. It's a program to recive DMX.
What I am trying to do, is to be able to change the DMX channel with a remote control, but the program does not recognize a variable and I can't find the problem.
I am using Picbasic 2.46 and I am mixing basic with assembly.
The circuit has two PICs. The first PIC receives the signal from the IR remote control and sends the information decoded to the next PIC via RS 232. The information received
on this PIC is correct, but when I put the variable in the program it doesn't work.
I have tried defining the variable in basic and in asm but none of them work.
Here is an example in basic:
Rich (BB code):
Dir=1 ; Dir is the variable for the DMX channel
CHAN
INCF _Offset
MOVF _Offset,W
XORLW _Dir ; When I put the variable "Dir" on this channel it doesn't work >>
BTFSC STATUS,Z ; but if I put any number (01h or 1) it works Perfectly.
GOTO CHAN2
Rich (BB code):
Dir equ 020h
movlw 01h
movwf Dir ; The value of Dir will not change, it remains with 020h.
Rich (BB code):
'-------------------------------------------------------------------------------
@ DEVICE pic16f628a,HS_OSC,MCLR_OFF,PWRT_ON,WDT_OFF,lvp_off,protect_on,CPD_on
INCLUDE "modedefs.bas"
define OSC 20
x var byte
Dir var byte
OUT1 var PORTA.4
OUT2 var PORTB.4
OUT3 var PORTB.5
OUT4 var PORTB.6
OUT5 var PORTB.7
OUT6 var PORTA.1
OUT7 var PORTB.2
BREAK var byte
STARTCODE var byte
ADDR9 var byte
RC9 var byte
Reg1 var byte
Reg2 var byte
Reg3 var byte
Reg4 var byte
Reg5 var byte
Reg6 var byte
Reg7 var byte
WSAVE var byte $20 system
SSAVE var byte bank0 system
PSAVE var byte bank0 system
pwmcounter var byte
DADDR var byte
RADDR var byte
Offset var byte
DEFINE INTHAND ISR
asm
goto INICIO
ISR
bcf INTCON,GIE
btfsc INTCON,GIE
GoTo ISR
movwf WSAVE
movf STATUS,W
clrf STATUS
movwf SSAVE
movf PCLATH
movwf PSAVE
clrf PCLATH
GOTO INTHANDLER
INICIO
endasm
CMCON=7
TRISA= %00000000
TRISB= %00001010
low PortA.2
high PortB.3
pause 100
Loop1:
if PortB.3=0 then goto Loop1
Loop2:
serin PortB.3,T9600,x
if x=0 then goto Loop2 ' It stays here until it receives from other PIC
write 2,x
read 2,Dir
Dir=1 ' Only for test <<<<<<<<<<<<
asm
movlw 01h
movwf Dir
endasm
SPBRG = 4
TXSTA = %00100100
PIE1.5=1
RCSTA.6=1
RCREG=0
RCREG=0
RCREG=0
RCSTA = $90
RCSTA.7=1
INTCON.6=1
INTCON.7=1
Reg1=0
Reg2=0
Reg3=0
Reg4=0
Reg5=0
Reg6=0
Reg7=0
DADDR=0
ADDR9=0
MAIN:
'low RX
pwmcounter=255
OUT1=0
OUT2=0
OUT3=0
OUT4=0
OUT5=0
OUT6=0
OUT7=0
@ call PWM_CYCLE
goto MAIN
asm
PWM_CYCLE
MOVF _Reg1,W
XORWF _pwmcounter,W
BTFSC STATUS,Z
BSF _OUT1
MOVF _Reg2,W
XORWF _pwmcounter,W
BTFSC STATUS,Z
BSF _OUT2
MOVF _Reg3,W
XORWF _pwmcounter,W
BTFSC STATUS,Z
BSF _OUT3
MOVF _Reg4,W
XORWF _pwmcounter,W
BTFSC STATUS,Z
BSF _OUT4
MOVF _Reg5,W
XORWF _pwmcounter,W
BTFSC STATUS,Z
BSF _OUT5
MOVF _Reg6,W
XORWF _pwmcounter,W
BTFSC STATUS,Z
BSF _OUT6
MOVF _Reg7,W
XORWF _pwmcounter,W
BTFSC STATUS,Z
BSF _OUT7
DECFSZ _pwmcounter
GOTO PWM_CYCLE
RETURN
INTRETURN
MOVF PSAVE,W
MOVWF PCLATH
MOVF SSAVE,W
MOVWF STATUS
SWAPF WSAVE,F
SWAPF WSAVE,W
RETFIE
INTHANDLER
BTFSS PIR1,RCIF
GOTO INTRETURN
GOTO DMX
DMX
BSF PORTA,2
BTFSC RCSTA,OERR
GOTO OVERRUN
BTFSC RCSTA,FERR
GOTO FRAME
BTFSS _BREAK
GOTO RET
BTFSS _STARTCODE
GOTO SC
BTFSC _STARTCODE
GOTO CHANNEL
RET
MOVF RCREG,W
GOTO INTRETURN
OVERRUN
BCF RCSTA,SPEN
BSF RCSTA,SPEN
MOVF RCREG,W
GOTO LAST
FRAME
BCF _BREAK
BCF _STARTCODE
BCF _RC9
CLRF _RADDR
CLRF _Offset
BTFSS RCSTA,RX9D
BSF _BREAK
MOVF RCREG,W
GOTO INTRETURN
SC
MOVF RCREG,W
XORLW 00h
BTFSC STATUS,Z
BSF _STARTCODE
GOTO INTRETURN
INCREASE
INCF _RADDR
BTFSC STATUS,Z
BSF _RC9
RETURN
CHANNEL
MOVF _Offset,W
XORLW 00h
BTFSS STATUS,Z
GOTO CHAN
MOVF _RADDR,W
XORWF _DADDR,W
BTFSC STATUS,Z
GOTO NINTH
CALL INCREASE
GOTO RET
NINTH
BTFSC _ADDR9
GOTO TRUE
MOVF RCREG,W
GOTO FALSE
TRUE
BTFSC _RC9
GOTO CHAN
CALL INCREASE
GOTO RET
FALSE
BTFSS _RC9
GOTO CHAN
CALL INCREASE
GOTO RET
CHAN
INCF _Offset
MOVF _Offset,W
XORLW _Dir ; << When I put the variable Dir, it doesn't work. But if I put any
BTFSC STATUS,Z ; number it works perfectly.
GOTO CHAN2
MOVF _Offset,W
XORLW 2 ; ok
BTFSC STATUS,Z
GOTO CHAN3
MOVF _Offset,W
XORLW 3 ; ok
BTFSC STATUS,Z
GOTO CHAN4
MOVF _Offset,W
XORLW 4 ; ok
BTFSC STATUS,Z
GOTO CHAN5
MOVF _Offset,W
XORLW 5 ; ok
BTFSC STATUS,Z
GOTO CHAN6
MOVF _Offset,W
XORLW 6 ; ok
BTFSC STATUS,Z
GOTO CHAN7
MOVF _Offset,W
XORLW 0FFh
BTFSC STATUS,Z
GOTO LAST
CHAN1
MOVF RCREG,W
MOVWF _Reg1
CALL INCREASE
GOTO INTRETURN
CHAN2
MOVF RCREG,W
MOVWF _Reg2
CALL INCREASE
GOTO INTRETURN
CHAN3
MOVF RCREG,W
MOVWF _Reg3
CALL INCREASE
GOTO INTRETURN
CHAN4
MOVF RCREG,W
MOVWF _Reg4
CALL INCREASE
GOTO INTRETURN
CHAN5
MOVF RCREG,W
MOVWF _Reg5
CALL INCREASE
GOTO INTRETURN
CHAN6
MOVF RCREG,W
MOVWF _Reg6
CALL INCREASE
GOTO INTRETURN
CHAN7
MOVF RCREG,W
MOVWF _Reg7
CALL INCREASE
GOTO INTRETURN
LAST
BCF _BREAK
BCF _STARTCODE
CLRF _Offset
GOTO INTRETURN
;-------------------------------------------------------------------------------
endasm
end
Thank you very much for the help.
Last edited by a moderator: