compiling problem with MPLAB

Discussion in 'Embedded Systems and Microcontrollers' started by dreamcatcher, Jun 17, 2010.

  1. dreamcatcher

    Thread Starter New Member

    Jan 5, 2010
    27
    0
    hi,

    i'm a begginer user of MPLAB and i've wrote this programme that control two motors
    the problem is when i try to compile it there is a error that i don't know how to solve it
    the windows showing the error is as an attached file

    and here is my source code:

    List p=16f877
    include<p16f877.inc>
    __CONFIG _CP_OFF & _DEBUG_OFF & _WRT_ENABLE_ON & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _PWRTE_OFF & _WDT_OFF & _HS_OSC

    errorlevel-302

    D1 EQU 0X070
    D2 EQU 0X071
    D3 EQU 0X072
    CNT EQU 0X073

    DR EQU 0
    CKR EQU 1
    HF EQU 2
    DL EQU 3
    CKL EQU 4

    ORG 0X000
    GOTO MAIN

    ORG 0X004
    RETFIE

    MAIN

    BANK0 macro
    bcf STATUS,RP0
    BCF STATUS,RP1
    endm
    BANK1 macro
    BSF STATUS,RP0
    BCF STATUS,RP1
    endm

    ;;;;;;;;;;;;;;;;;****************PORT OUTPUT CONFIG**************;;;;;;;;;;;

    ;BSF STATUS,RP0 ;SELECT BANK1
    BANK1
    MOVLW 0x00 ;SET TRISA AS OUTPUT
    MOVWF TRISA
    MOVLW B'00000110' ;SET TRISE AS OUTPUT(E0) AND INPUT(E1,E2)
    MOVWF TRISE
    BCF OPTION_REG,5
    ;BCF STATUS,5
    BANK0
    ;;;;;;;;;;;;;;;;;****************MAIN PROGRAM**************;;;;;;;;;;;
    ORG 0X000
    GOTO AZ1

    ORG 0X004
    RETFIE


    AZ1 DECFSZ CNT,1
    GOTO F1
    RETURN

    AZ2 DECFSZ CNT,1
    GOTO B1
    RETURN

    AZ3 DECFSZ CNT,1
    GOTO R1
    RETURN

    AZ4 DECFSZ CNT,1
    GOTO L1
    RETURN


    F1 CALL FORWARD
    GOTO AZ1

    B1 CALL BACK
    GOTO AZ2

    R1 CALL RIGHT
    GOTO AZ3

    L1 CALL LEFT
    GOTO AZ4


    ;********************* MOTOR SUBROUTINES ******************************

    FORWARD BSF PORTA,DR
    BSF PORTA,DL
    MOVLW B'00010010'
    XORWF PORTA,1
    CALL DELMOT
    MOVLW B'00010010'
    XORWF PORTA,1
    CALL DELMOT
    RETURN

    BACK BCF PORTA,DR
    BCF PORTA,DL
    MOVLW B'00010010'
    XORWF PORTA,1
    CALL DELMOT
    MOVLW B'00010010'
    XORWF PORTA,1
    CALL DELMOT
    RETURN

    RIGHT BSF PORTA,DR
    BCF PORTA,DL
    MOVLW B'00010010'
    XORWF PORTA,1
    CALL DELMOT
    MOVLW B'00010010'
    XORWF PORTA,1
    CALL DELMOT
    RETURN

    LEFT BCF PORTA,DR
    BSF PORTA,DL
    MOVLW B'00010010'
    XORWF PORTA,1
    CALL DELMOT
    MOVLW B'00010010'
    XORWF PORTA,1
    CALL DELMOT
    RETURN


    DELMOT MOVLW 0X07
    MOVWF D1
    CLRF D2
    CLRF D3

    WM1 DECFSZ D1,1
    GOTO WM
    RETURN

    WM DECFSZ D2,1
    GOTO WM2
    GOTO WM1

    WM2 DECFSZ D3,1
    GOTO WM2
    GOTO WM


    END
     
  2. Vaughanabe13

    Active Member

    May 4, 2009
    102
    5
    Remove the linker (.lkr) file from your project and try building again. It's failing on the link step. If it still doesn't work, use the project wizard to create a new project and use MPASM Assembler as your active tool suite. Then add your .asm file to the project and try building again.
     
  3. dreamcatcher

    Thread Starter New Member

    Jan 5, 2010
    27
    0
    I don't know how to do this
    also I didn't add any .lkr file , i've added only .asm file

    pls would you explane me breifly how can i do it

    thank you
     
  4. Vaughanabe13

    Active Member

    May 4, 2009
    102
    5
    1. Open MPLAB
    2. Project->Project Wizard
    3. Click next. Then select your PIC device and click Next again.
    4. Click the upper dropdown menu and select "Microchip MPASM Toolsuite" and click Next.
    5. Create a new project file somewhere on your computer. I usually create a folder for a project and then create the project file inside this folder. Click next.
    6. Now it will ask you to add project files. Just click "next" for now and skip this. Click finish to end the project wizard. You should now be looking at a blank project in MPLAB.
    7. Right click the "source files" folder on the browser on the left of the screen and select "add files." Select your source .asm file with your code in it. You might want to move that file to your project folder first, but it doesn't matter where it is.
    8. Now click Project->Build Options-> Project and go to the "Directories" tab. Select "Library Search Path" in the drop down.
    9. Click "New" and then click the "..." button to browse for your include directory. This is the folder where your "picxxxxx.inc" file is located. I think the default location is "C:\Program Files\Microchip\MPASM Suite".
    10. Now change the dropdown menu to "Linker-script search path" at the top and add a new search path. Use "C:\Program Files\Microchip\MPASM Suite\LKR" as the directory.
    11. Click ok to get back to the project window. Now go to Project->Build all and hopefully it works. Let me know if you still get errors.
     
  5. dreamcatcher

    Thread Starter New Member

    Jan 5, 2010
    27
    0
    Thank you for your help but the problem was in my source code

    i've done org 0x000 twice

    thank you very much for your help
     
  6. Vaughanabe13

    Active Member

    May 4, 2009
    102
    5
    Gotcha, that will definitely do it.
     
Loading...