1. 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.
    Dismiss Notice

Unable to get some code to build and can't figure out why.

Discussion in 'Microcontrollers' started by Chris244, Dec 7, 2017.

  1. Chris244

    Chris244 New Member

    Joined:
    Dec 7, 2017
    Messages:
    2
    Likes:
    0
    Hello, I am very new to coding and have to do a bit for a course im doing at the moment.
    (sorry if this is the wrong place for this)

    I am using MPLAB to get a LED to move and am getting this fault, apart from this the rest looks good but i cant work out what it want me to do with the label as it seems ok to me?

    Code (Asm):

    .ASM 11 : Labels must be defined in a code or data section when making an object file

    ; U19A2T1-4.asm
    ; blinks LEDs on outputs in a rotating pattern, with input option to reverse direction
    ;Set microprocessor as 16F84
       INCLUDE <P16F84.INC>
    ; Setup processor configuration
       __CONFIG _RC_OSC & _WDT_OFF & _PWRTE_ON
    ; label 2 symbols as memory addresses for counting loops
    J EQU 1F
    K EQU 1E

    SETUP:
           ORG 0 ;
           BANKSEL TRISA ;
           CLRF TRISA ;
           BCF STATUS , RP0 ;
           BCF STATUS , RP1 ;
           MOVLW 0X01 ;
           MOVWF PORTB ;
           BCF STATUS,C ;

    ROTATE:
           BTFSS PORTA,0 ;
           GOTO RR
           RLF PORTB,F ;
           GOTO DELAY
    RR:       RRF PORTB,F ;

    DELAY:
           MOVLW 0X32 ;
           MOVWF J ;
    JLOOP:        MOVWF K ;
    KLOOP:        DECFSZ K,F ;
           GOTO KLOOP
           DECFSZ J,F ;
           GOTO JLOOP

    DIRECTION:
           MOVLW 0X02 ;
           XORWF PORTA,0;
           GOTO ROTATE ;
           END

     
    Any help would be great thank you
     
  2. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,293
    Likes:
    356
    Location:
    Brisbane Australia
    Your label SETUP is before your org directive. Swap them.

    Mike.
     
  3. Chris244

    Chris244 New Member

    Joined:
    Dec 7, 2017
    Messages:
    2
    Likes:
    0
    Mate, you're a lifesaver cheers.
     

Share This Page