Help with variables: DMX receiver

Discussion in 'Embedded Systems and Microcontrollers' started by loesvan, Sep 23, 2011.

  1. loesvan

    Thread Starter New Member

    Sep 23, 2011
    9
    0
    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:

    Code ( (Unknown Language)):
    1.  
    2. Dir=1 ; Dir is the variable for the DMX channel
    3.  
    4. CHAN
    5.  INCF    _Offset
    6.  MOVF    _Offset,W    
    7.  XORLW    _Dir        ; When I put the variable "Dir" on this channel it doesn't work >>
    8.  BTFSC    STATUS,Z    ; but if I put any number (01h or 1) it works Perfectly.
    9.  GOTO    CHAN2
    10.  
    But even if I do it in assembly it doesn't work
    Code ( (Unknown Language)):
    1.  
    2. Dir equ 020h
    3.  movlw  01h
    4.  movwf  Dir   ; The value of Dir will not change, it remains with 020h.
    5.  
    Here is the complete program:


    Code ( (Unknown Language)):
    1.  
    2. '-------------------------------------------------------------------------------
    3.  
    4.  
    5.  
    6. @ DEVICE pic16f628a,HS_OSC,MCLR_OFF,PWRT_ON,WDT_OFF,lvp_off,protect_on,CPD_on
    7. INCLUDE "modedefs.bas"
    8.  
    9. define OSC 20
    10.  
    11. x   var byte  
    12. Dir var byte
    13.  
    14. OUT1 var PORTA.4    
    15. OUT2 var PORTB.4    
    16. OUT3 var PORTB.5
    17. OUT4 var PORTB.6
    18. OUT5 var PORTB.7    
    19. OUT6 var PORTA.1    
    20. OUT7 var PORTB.2
    21.  
    22. BREAK var byte
    23. STARTCODE var byte
    24. ADDR9 var byte
    25. RC9   var byte
    26.  
    27. Reg1    var byte
    28. Reg2    var byte
    29. Reg3    var byte
    30. Reg4    var byte
    31. Reg5    var byte
    32. Reg6    var byte
    33. Reg7    var byte
    34.  
    35. WSAVE  var byte   $20 system      
    36. SSAVE  var byte bank0 system
    37. PSAVE  var byte bank0 system
    38. pwmcounter var byte
    39.  
    40. DADDR   var byte
    41. RADDR   var byte
    42. Offset  var byte
    43.  
    44. DEFINE INTHAND ISR  
    45.  
    46. asm
    47.  
    48.  goto INICIO
    49. ISR
    50.  bcf     INTCON,GIE      
    51.  btfsc   INTCON,GIE      
    52.  GoTo    ISR            
    53.  movwf   WSAVE          
    54.  movf    STATUS,W
    55.  clrf    STATUS          
    56.  movwf   SSAVE          
    57.  movf    PCLATH          
    58.  movwf   PSAVE          
    59.  clrf    PCLATH          
    60.  
    61.  GOTO INTHANDLER
    62.  
    63. INICIO
    64. endasm
    65. CMCON=7
    66.  
    67. TRISA= %00000000
    68. TRISB= %00001010
    69.  
    70. low PortA.2
    71. high PortB.3
    72. pause 100
    73.  
    74. Loop1:
    75. if PortB.3=0 then goto Loop1
    76. Loop2:
    77. serin PortB.3,T9600,x
    78. if x=0 then goto Loop2  ' It stays here until it receives from other PIC
    79.                        
    80. write 2,x      
    81. read  2,Dir    
    82.  
    83. Dir=1             '               Only for test <<<<<<<<<<<<
    84. asm
    85.  movlw 01h
    86.  movwf Dir
    87.  
    88. endasm
    89.  
    90.  
    91.  
    92.  
    93. SPBRG = 4          
    94. TXSTA = %00100100  
    95. PIE1.5=1
    96. RCSTA.6=1          
    97.  
    98. RCREG=0
    99. RCREG=0
    100. RCREG=0
    101. RCSTA = $90
    102. RCSTA.7=1
    103. INTCON.6=1  
    104. INTCON.7=1
    105.  
    106. Reg1=0
    107. Reg2=0
    108. Reg3=0
    109. Reg4=0
    110. Reg5=0
    111. Reg6=0
    112. Reg7=0
    113. DADDR=0
    114. ADDR9=0    
    115.  
    116. MAIN:
    117. 'low RX
    118. pwmcounter=255
    119. OUT1=0
    120. OUT2=0
    121. OUT3=0
    122. OUT4=0
    123. OUT5=0
    124. OUT6=0
    125. OUT7=0
    126. @ call PWM_CYCLE
    127. goto MAIN
    128.  
    129. asm
    130. PWM_CYCLE
    131.  
    132.  MOVF    _Reg1,W
    133.  XORWF    _pwmcounter,W
    134.  BTFSC    STATUS,Z
    135.  BSF    _OUT1
    136.  MOVF    _Reg2,W
    137.  XORWF    _pwmcounter,W
    138.  BTFSC    STATUS,Z
    139.  BSF    _OUT2
    140.  MOVF    _Reg3,W
    141.  XORWF    _pwmcounter,W
    142.  BTFSC    STATUS,Z
    143.  BSF    _OUT3
    144.  MOVF    _Reg4,W
    145.  XORWF    _pwmcounter,W
    146.  BTFSC    STATUS,Z
    147.  BSF    _OUT4
    148.  MOVF    _Reg5,W
    149.  XORWF    _pwmcounter,W
    150.  BTFSC    STATUS,Z
    151.  BSF    _OUT5
    152.  MOVF    _Reg6,W
    153.  XORWF    _pwmcounter,W
    154.  BTFSC    STATUS,Z
    155.  BSF    _OUT6
    156.  MOVF    _Reg7,W
    157.  XORWF    _pwmcounter,W
    158.  BTFSC    STATUS,Z
    159.  BSF    _OUT7
    160.  
    161.  DECFSZ    _pwmcounter
    162.  GOTO    PWM_CYCLE
    163.  RETURN
    164.  
    165. INTRETURN
    166.  MOVF    PSAVE,W    
    167.  MOVWF    PCLATH
    168.  MOVF    SSAVE,W
    169.  MOVWF    STATUS
    170.  SWAPF    WSAVE,F  
    171.  SWAPF    WSAVE,W
    172.  RETFIE        
    173.  
    174. INTHANDLER
    175.  BTFSS    PIR1,RCIF
    176.  GOTO    INTRETURN
    177.  GOTO    DMX
    178.  
    179. DMX
    180.  BSF    PORTA,2  
    181.  BTFSC    RCSTA,OERR
    182.  GOTO    OVERRUN
    183.  
    184.  BTFSC     RCSTA,FERR
    185.  GOTO     FRAME
    186.  
    187.  BTFSS     _BREAK
    188.  GOTO     RET
    189.  
    190.  BTFSS    _STARTCODE    
    191.  
    192.  GOTO    SC            
    193.  BTFSC    _STARTCODE
    194.  GOTO    CHANNEL
    195.  
    196. RET
    197.  MOVF    RCREG,W
    198.  GOTO    INTRETURN
    199.  
    200. OVERRUN
    201.  BCF    RCSTA,SPEN
    202.  BSF    RCSTA,SPEN
    203.  MOVF    RCREG,W
    204.  GOTO    LAST
    205.  
    206. FRAME
    207.  BCF    _BREAK
    208.  BCF    _STARTCODE
    209.  BCF    _RC9
    210.  CLRF    _RADDR
    211.  CLRF    _Offset
    212.  BTFSS    RCSTA,RX9D
    213.  BSF    _BREAK
    214.  MOVF    RCREG,W
    215.  GOTO    INTRETURN
    216.  
    217. SC
    218.  MOVF    RCREG,W
    219.  XORLW    00h
    220.  BTFSC    STATUS,Z
    221.  BSF    _STARTCODE
    222.  GOTO    INTRETURN
    223.  
    224. INCREASE
    225.  INCF    _RADDR    
    226.  BTFSC    STATUS,Z
    227.  BSF    _RC9
    228.  RETURN
    229.  
    230. CHANNEL
    231.  
    232.  MOVF    _Offset,W
    233.  XORLW    00h            
    234.  BTFSS    STATUS,Z
    235.  GOTO    CHAN
    236.  
    237.  MOVF    _RADDR,W    
    238.  XORWF    _DADDR,W
    239.  BTFSC    STATUS,Z
    240.  GOTO    NINTH        
    241.  
    242.  CALL    INCREASE
    243.  GOTO    RET
    244.  
    245. NINTH
    246.  BTFSC    _ADDR9
    247.  GOTO    TRUE
    248.  MOVF    RCREG,W
    249.  GOTO    FALSE
    250.  
    251. TRUE
    252.  BTFSC    _RC9
    253.  GOTO    CHAN
    254.  CALL    INCREASE
    255.  GOTO    RET
    256.  
    257. FALSE
    258.  BTFSS    _RC9
    259.  GOTO    CHAN
    260.  CALL    INCREASE
    261.  GOTO    RET
    262.  
    263. CHAN
    264.  INCF    _Offset
    265.  MOVF    _Offset,W    
    266.  XORLW    _Dir     ; << When I put the variable Dir, it doesn't work. But if I put any
    267.  BTFSC    STATUS,Z ;    number it works perfectly.
    268.  GOTO    CHAN2
    269.  MOVF    _Offset,W
    270.  XORLW    2         ;   ok
    271.  BTFSC    STATUS,Z
    272.  GOTO    CHAN3
    273.  MOVF    _Offset,W
    274.  XORLW    3         ;   ok
    275.  BTFSC    STATUS,Z
    276.  GOTO    CHAN4
    277.  MOVF    _Offset,W
    278.  XORLW    4         ;   ok
    279.  BTFSC    STATUS,Z
    280.  GOTO    CHAN5
    281.  MOVF    _Offset,W
    282.  XORLW    5         ;   ok
    283.  BTFSC    STATUS,Z
    284.  GOTO    CHAN6
    285.  MOVF    _Offset,W
    286.  XORLW    6        ;    ok
    287.  BTFSC    STATUS,Z
    288.  GOTO    CHAN7
    289.  
    290.  MOVF    _Offset,W
    291.  XORLW    0FFh              
    292.  BTFSC    STATUS,Z
    293.  GOTO    LAST
    294.  
    295. CHAN1
    296.  MOVF    RCREG,W
    297.  MOVWF    _Reg1
    298.  CALL    INCREASE
    299.  GOTO    INTRETURN
    300.  
    301. CHAN2
    302.  MOVF    RCREG,W
    303.  MOVWF    _Reg2
    304.  CALL    INCREASE
    305.  GOTO    INTRETURN
    306.  
    307. CHAN3
    308.  MOVF    RCREG,W
    309.  MOVWF    _Reg3
    310.  CALL    INCREASE
    311.  GOTO    INTRETURN
    312.  
    313. CHAN4
    314.  MOVF    RCREG,W
    315.  MOVWF    _Reg4
    316.  CALL    INCREASE
    317.  GOTO    INTRETURN
    318.  
    319. CHAN5
    320.  MOVF    RCREG,W
    321.  MOVWF    _Reg5
    322.  CALL    INCREASE
    323.  GOTO    INTRETURN
    324.  
    325. CHAN6
    326.  MOVF    RCREG,W
    327.  MOVWF    _Reg6
    328.  CALL    INCREASE
    329.  GOTO    INTRETURN
    330.  
    331. CHAN7
    332.  MOVF    RCREG,W
    333.  MOVWF    _Reg7
    334.  CALL    INCREASE
    335.  GOTO    INTRETURN
    336.  
    337. LAST
    338.  
    339.  BCF    _BREAK
    340.  BCF    _STARTCODE
    341.  CLRF    _Offset
    342.  GOTO    INTRETURN
    343. ;-------------------------------------------------------------------------------
    344.  
    345. endasm
    346.  
    347.  end
    348.  

    Thank you very much for the help.
     
    Last edited by a moderator: Sep 23, 2011
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,607
    Due to it's limited addressing size inside an instruction, PICs spread the register memory over several banks. Thus an address 0x20 exists in banks 0, 1 and 2 for that device.

    You need to proceed your instruction to write to Dir with a "banksel Dir" macro instruction. Normally you don't need to mess with that in something like Basic, but since you're mixing assembly and Basic together you need to do it in the assembly code parts.

    I'm not sure if your Basic has the banksel macro, it's a standard Microchip MPLAB assembly macro.

    Hope that helps. :rolleyes:
     
    loesvan likes this.
  3. loesvan

    Thread Starter New Member

    Sep 23, 2011
    9
    0
    Thanks for your help but I still have the problem, when I put banksel I get the error opcode expected instead of Dir. I have tried switching to other banks but it doesn't work.
     
  4. loesvan

    Thread Starter New Member

    Sep 23, 2011
    9
    0
    Thanks for your help ErnieM, but I sill have the problem. When I put banksel I get
    a error opcode inspected instead of Dir. I have tried switching to other banks but it doesn't work.
     
  5. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,607
    Two choices: either figure out how to do bank selection for inline assembler, or change the whole project to assembler.

    The bank is set in the Status register by the RP bits.

    However, the very top of memory 0x70 - 0X7F appear in all banks and need not be selected. If your compiler doesn't use them you can use one of those instead of address 0x20 to hold Dir_
     
    loesvan likes this.
  6. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    in your first example you are using xorlw incorrectly, it would xor the memory address of Dir and W.
    You should use XORWF _Dir, W (assuming you don't want to change Dir).
     
  7. loesvan

    Thread Starter New Member

    Sep 23, 2011
    9
    0
    Hi ErnieM,
    If I do it all in assembly (without the part in basic just giving a value to Dir) I have the same problem. the Variable Dir is not working.
    I will try what you said of the top of memory.
    Thanks.
     
  8. loesvan

    Thread Starter New Member

    Sep 23, 2011
    9
    0
    Hi Markd77
    If I put XORWF _Dir,W I get a error: extra tokens on end of line.
    Thanks for your help.
     
  9. loesvan

    Thread Starter New Member

    Sep 23, 2011
    9
    0
    Here is how the program looks now, but it's still not woking:



    Code ( (Unknown Language)):
    1. __CONFIG _CP_ON &_PWRTE_ON &_WDT_OFF &_HS_OSC &_LVP_OFF &_MCLRE_OFF ;&_CPD_ON
    2.  
    3.  
    4.  list    P=16F628A
    5.  #INCLUDE <P16F628a.INC>
    6.  
    7.  #DEFINE    OUT1  PORTA,4    
    8.  #DEFINE    OUT2  PORTB,4    
    9.  #DEFINE    OUT3  PORTB,5
    10.  #DEFINE    OUT4  PORTB,6
    11.  #DEFINE    OUT5  PORTB,7    
    12.  #DEFINE    OUT6  PORTA,0    
    13.  #DEFINE    OUT7  PORTA,1    
    14.  
    15.  #DEFINE    BREAK      DMX_reg,0
    16.  #DEFINE    STARTCODE DMX_reg,1
    17.  #DEFINE    MOVED      DMX_reg,2
    18.  #DEFINE    ADDR9      DMX_reg,3
    19.  #DEFINE    RC9      DMX_reg,4
    20.  
    21. [COLOR=Red]Dir     EQU     0x70 ;   Variable [/COLOR]>>>>>>>>>>>>>
    22.  
    23. DMX_reg EQU     020h
    24. Reg1    EQU     021h
    25. Reg2    EQU     022h
    26. Reg3    EQU    023h
    27. Reg4    EQU    024h
    28. Reg5    EQU    025h
    29. Reg6    EQU    026h
    30. Reg7    EQU    027h
    31. Count    EQU    030h
    32. W_SAVE    EQU    031h
    33. S_SAVE    EQU    032h
    34. P_SAVE    EQU    033h
    35. pwmcounter EQU  034h
    36. flag        EQU    02Ah
    37. D_ADDR   EQU    02Bh
    38. temp       EQU    02Ch
    39. R_ADDR   EQU    02Dh
    40. Offset     EQU    02Eh
    41. temp2     EQU    02Fh
    42.  
    43.  ORG 00h
    44.  GOTO INIT
    45.  
    46.  ORG 04h
    47.  MOVWF    W_SAVE      ;save context,
    48.  MOVF    STATUS,W  ;save  STATUS, PCLATH & W
    49.  MOVWF    S_SAVE
    50.  MOVF PCLATH,W
    51.  MOVWF P_SAVE
    52.  GOTO INTHANDLER
    53. INIT
    54.  
    55.  MOVLW    0x07    ;turn analog comparators off
    56.  MOVWF    CMCON
    57.  CLRF    PORTA
    58.  CLRF    PORTB
    59.  
    60.  BSF    STATUS,RP0 ;Select Bank1
    61.  CLRF    TRISA       ;porta output
    62.  CLRF    TRISB       ;portb output
    63.  BSF    TRISB,1       ;B1 input (UART Recieve)
    64.  
    65.  [COLOR=Red]MOVLW 01h    
    66.  MOVWF Dir    ; Dir = 1[/COLOR] >>>>>>>>>>>>>>>>>>>>>>>>
    67.  
    68.  
    69.  
    70.  
    71.  MOVLW    04h
    72.  MOVWF    SPBRG            ;Set baud rate
    73.  BSF    TXSTA,BRGH    ;high speed
    74.  BCF    TXSTA,SYNC    ;Async connection
    75.  CLRF    PIE1            ;clear other interrupts
    76.  BSF    PIE1,RCIE    ;Set recieve interrupt
    77.  BCF    STATUS,RP0    ;Return to bank0
    78.  BSF    RCSTA,RX9    ;Enable 9bit data
    79.  
    80.  MOVF    RCREG,W    ;clear RCREG FIFO
    81.  MOVF    RCREG,W
    82.  MOVF    RCREG,W
    83.  BSF    RCSTA,CREN    ;Enable recieve
    84.  BSF    RCSTA,SPEN    ;Enable UART
    85.  BSF    INTCON,PEIE    ;Enable interrupts
    86.  BSF    INTCON,GIE
    87.  
    88.  CLRF    Reg1
    89.  CLRF    Reg2
    90.  CLRF    Reg3
    91.  CLRF    Reg4
    92.  CLRF    Reg5
    93.  CLRF    Reg6
    94.  CLRF    Reg7
    95.  ;CLRF    Reg8
    96.  ;CLRF    Reg9
    97.  CLRF    D_ADDR    ;set our dmx adress to 0
    98.  BCF    ADDR9
    99.  
    100.  GOTO MAIN
    101. MAIN
    102.  MOVLW    0FFh
    103.  MOVWF    pwmcounter
    104.  BCF    OUT1
    105.  BCF    OUT2
    106.  BCF    OUT3
    107.  BCF    OUT4
    108.  BCF    OUT5
    109.  BCF    OUT6
    110.  BCF    OUT7
    111.  
    112.  CALL    PWM_CYCLE
    113.  
    114.  GOTO    MAIN
    115.  
    116. PWM_CYCLE
    117.  MOVF    Reg1,W
    118.  XORWF    pwmcounter,W
    119.  BTFSC    STATUS,Z
    120.  BSF    OUT1
    121.  MOVF    Reg2,W
    122.  XORWF    pwmcounter,W
    123.  BTFSC    STATUS,Z
    124.  BSF    OUT2
    125.  MOVF    Reg3,W
    126.  XORWF    pwmcounter,W
    127.  BTFSC    STATUS,Z
    128.  BSF    OUT3
    129.  MOVF    Reg4,W
    130.  XORWF    pwmcounter,W
    131.  BTFSC    STATUS,Z
    132.  BSF    OUT4
    133.  MOVF    Reg5,W
    134.  XORWF    pwmcounter,W
    135.  BTFSC    STATUS,Z
    136.  BSF    OUT5
    137.  MOVF    Reg6,W
    138.  XORWF    pwmcounter,W
    139.  BTFSC    STATUS,Z
    140.  BSF    OUT6
    141.  MOVF    Reg7,W
    142.  XORWF    pwmcounter,W
    143.  BTFSC    STATUS,Z
    144.  BSF    OUT7
    145.  
    146.  DECFSZ    pwmcounter
    147.  GOTO    PWM_CYCLE
    148.  RETURN
    149.  
    150. INTRETURN
    151.  MOVF    P_SAVE,W    ;restore context
    152.  MOVWF    PCLATH
    153.  MOVF    S_SAVE,W
    154.  MOVWF    STATUS
    155.  SWAPF    W_SAVE,F
    156.  SWAPF    W_SAVE,W
    157.  RETFIE
    158.  
    159. INTHANDLER
    160.  BTFSS    PIR1,RCIF
    161.  GOTO    INTRETURN
    162.  GOTO    DMX
    163.  
    164. DMX
    165.  BTFSC    RCSTA,OERR
    166.  GOTO    OVERRUN
    167.  
    168.  BTFSC     RCSTA,FERR
    169.  GOTO     FRAME
    170.  
    171.  BTFSS     BREAK
    172.  GOTO     RET
    173.  
    174.  BTFSS    STARTCODE    ;has a startcode passed ?
    175.  
    176.  GOTO    SC            ;yes: go check for valid startcode
    177.  
    178.  BTFSC    STARTCODE
    179.  
    180.  GOTO    CHANNEL
    181.  
    182. RET
    183.  MOVF    RCREG,W
    184.  GOTO    INTRETURN
    185.  
    186. OVERRUN
    187.  BCF    RCSTA,SPEN
    188.  BSF    RCSTA,SPEN
    189.  MOVF    RCREG,W
    190.  ;BSF    ERRLED
    191.  GOTO    LAST
    192.  
    193. FRAME
    194.  BCF    BREAK
    195.  BCF    STARTCODE
    196.  BCF    RC9
    197.  CLRF    R_ADDR
    198.  CLRF    Offset
    199.  BTFSS    RCSTA,RX9D
    200.  BSF    BREAK
    201.  MOVF    RCREG,W
    202.  GOTO    INTRETURN
    203.  
    204. SC
    205.  MOVF    RCREG,W
    206.  XORLW    00h
    207.  BTFSC    STATUS,Z
    208.  BSF    STARTCODE
    209.  GOTO    INTRETURN
    210.  
    211. INCREASE
    212.  INCF    R_ADDR    
    213.  BTFSC    STATUS,Z
    214.  BSF    RC9
    215.  RETURN
    216.  
    217. CHANNEL
    218.  
    219.  MOVF    Offset,W
    220.  XORLW    00h        ;check if offset != 0
    221.  BTFSS    STATUS,Z
    222.  GOTO    CHAN
    223.  
    224.  MOVF    R_ADDR,W    ;else: check if chans match
    225.  XORWF    D_ADDR,W
    226.  BTFSC    STATUS,Z
    227.  GOTO    NINTH        ;if so: check for 9th bit
    228.  
    229.  CALL    INCREASE
    230.  GOTO    RET
    231.  
    232. NINTH
    233.  BTFSC    ADDR9
    234.  GOTO    TRUE
    235.  MOVF    RCREG,W
    236.  GOTO    FALSE
    237.  
    238. TRUE
    239.  BTFSC    RC9
    240.  GOTO    CHAN
    241.  CALL    INCREASE
    242.  GOTO    RET
    243.  
    244. FALSE
    245.  BTFSS    RC9
    246.  GOTO    CHAN
    247.  CALL    INCREASE
    248.  GOTO    RET
    249.  
    250. CHAN
    251.  INCF    Offset
    252.  MOVF    Offset,W
    253.  [COLOR=Red]XORLW    Dir        ; Not working[/COLOR] >>>>>>>>>>>>>>>>>>>>>>
    254.  BTFSC    STATUS,Z
    255.  GOTO    CHAN2
    256.  
    257.  MOVF    Offset,W
    258.  XORLW    02h
    259.  BTFSC    STATUS,Z
    260.  GOTO    CHAN3
    261.  
    262.  MOVF    Offset,W
    263.  XORLW    03h
    264.  BTFSC    STATUS,Z
    265.  GOTO    CHAN4
    266.  
    267.  MOVF    Offset,W
    268.  XORLW    04h
    269.  BTFSC    STATUS,Z
    270.  GOTO    CHAN5
    271.  
    272.  MOVF    Offset,W
    273.  XORLW    05h
    274.  BTFSC    STATUS,Z
    275.  GOTO    CHAN6
    276.  
    277.  MOVF    Offset,W
    278.  XORLW    06h
    279.  BTFSC    STATUS,Z
    280.  GOTO    CHAN7
    281.  
    282.  MOVF    Offset,W
    283.  XORLW    0FFh
    284.  BTFSC    STATUS,Z
    285.  GOTO    LAST
    286.  
    287. CHAN1
    288.  MOVF    RCREG,W
    289.  MOVWF    Reg1
    290.  CALL    INCREASE
    291.  GOTO    INTRETURN
    292.  
    293. CHAN2
    294.  MOVF    RCREG,W
    295.  MOVWF    Reg2
    296.  CALL    INCREASE
    297.  GOTO    INTRETURN
    298.  
    299. CHAN3
    300.  MOVF    RCREG,W
    301.  MOVWF    Reg3
    302.  CALL    INCREASE
    303.  GOTO    INTRETURN
    304.  
    305. CHAN4
    306.  MOVF    RCREG,W
    307.  MOVWF    Reg4
    308.  CALL    INCREASE
    309.  GOTO    INTRETURN
    310.  
    311. CHAN5
    312.  MOVF    RCREG,W
    313.  MOVWF    Reg5
    314.  CALL    INCREASE
    315.  GOTO    INTRETURN
    316.  
    317. CHAN6
    318.  MOVF    RCREG,W
    319.  MOVWF    Reg6
    320.  CALL    INCREASE
    321.  GOTO    INTRETURN
    322.  
    323. CHAN7
    324.  MOVF    RCREG,W
    325.  MOVWF    Reg7
    326.  CALL    INCREASE
    327.  GOTO    INTRETURN
    328.  
    329. LAST
    330.  
    331.  BCF    BREAK
    332.  BCF    STARTCODE
    333.  CLRF    Offset
    334.  GOTO    INTRETURN
    335.  END
    336.  
    337.  
     
  10. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Now that you've changed to all assembler and presumably are using MPLAB, the suggestion I made should work.
     
  11. loesvan

    Thread Starter New Member

    Sep 23, 2011
    9
    0
    Hello Markd77,

    I am using the note book to make the asm file and Mpasmwin to compile, when I put XORLW Dir,W I get this error: Error[108] : Illegal character (,)
     
  12. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    What happens if you put XORWF Dir,W instead?
     
    loesvan likes this.
  13. loesvan

    Thread Starter New Member

    Sep 23, 2011
    9
    0
    Hello Markd77,

    If I put XORLW Dir,w I get a error Illegal character (,)
     
  14. loesvan

    Thread Starter New Member

    Sep 23, 2011
    9
    0
    Yes it works perfect. When I put XORWF Dir,W it works.

    Thank you very much for your help, I am very grateful for your help.

    I wish you all the best

     
    Last edited: Sep 25, 2011
Loading...