• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

error in code assembler

Status
Not open for further replies.

mpardinho

New Member
i use this code but then i compile occurs some errors
help me with erros in lines please

i use picsimulator ide / assembler to test the code above.
ERRORS ARE IN RED


Code:
    DataPin equ 0x06                  ;PIC Pin
    ClockPin equ 0x07                 ;PIC Pin 
    Char equ 0x35                      ;buffer
    BitCounter equ 0x36              ;number of bits to read

GetScanCode
    bsf STATUS, RP0                   ;select bank 1 
    sf TRISB, DataPin                  ;set pins as input
    bsf TRISB, ClockPin
    bcf OPTION_REG, NOT_RBPU    ;pull-ups are enabled
    bcf STATUS, RP0                   ;select bank 0

    call ClockWait                       ;wait for Pull up to take effect and                          keyboard to pull clock low

;--- Read Data Bits ----

ReadKey
    clrf Char                           ;
    movlw .8                          ;bits to read  
    movwf BitCounter

ReadChar
    rrf Char                           [COLOR="Red"]Error: Invalid argument[/COLOR]
    bcf Char, 7                       ;default value is 0
    call ClockWait                    ;wait for clock to go high then low

    btfss PORTB, DataPin              ;read Data
    goto Next                         [COLOR="Red"]Invalid argument of the instruction[/COLOR]
    bsf Char, 7                       ;Data is High
    Next decfsz BitCounter            [COLOR="Red"]Unrecognized instruction[/COLOR]        
    goto ReadChar                     ;read next Data Bit


call ClockWait                    ;Parity Bit

call ClockWait                    ;Stop Bit

;Pull Clock Line Low (keyboard will buffer any further keystrokes)

    bsf STATUS, RP0                   ;select bank 1
    bcf TRISB, ClockPin               ;set clock line as output
    bcf STATUS, RP0                   ;select bank 0 
    bcf PORTB, ClockPin               ;set clock line low


    movf Char, W
return

;----wait for clock to go high----
ClockWait
    btfss PORTB, ClockPin
    goto ClockWait

;----wait for clock to go low----
ClockWait2
    btfsc PORTB, ClockPin
    goto ClockWait2
 
Last edited:

Pommie

Well-Known Member
Most Helpful Member
I think you just need to indent your code so it looks like this.

Code:
DataPin equ 0x06                  ;PIC Pin
ClockPin equ 0x07                 ;PIC Pin
Char equ 0x35                     ;buffer
BitCounter equ 0x36               ;number of bits to read

GetScanCode
	bsf STATUS, RP0                   ;select bank 1
	bsf TRISB, DataPin                ;set pins as input
	bsf TRISB, ClockPin
	bcf OPTION_REG, NOT_RBPU          ;pull-ups are enabled
	bcf STATUS, RP0                   ;select bank 0

	call ClockWait                    ;wait for Pull up to take effect and keyboard to pull clock low
HTH

Mike.
 

StopGo

New Member
column 0 for 'labels' only, it needs spaces or tabs at the start of all non 'label' lines.
 

Pommie

Well-Known Member
Most Helpful Member
Try changing it to
Code:
ReadChar
    rrf Char,1                          ;Error: Invalid argument
    bcf Char, 7                       ;default value is 0
    call ClockWait                    ;wait for clock to go high then low

    btfss PORTB, DataPin              ;read Data
    goto Next                         ;Invalid argument of the instruction
    bsf Char, 7                       ;Data is High
Next decfsz BitCounter            ;Unrecognized instruction        
    goto ReadChar                     ;read next Data Bit
That should now assemble.

However, as Nigel says, the microchip assembler is better. Download MPLAB free from microchip.

Mike.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top