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

Why can't i build my simple program in MPLAB??PLEASE HELP!!!!:(

Discussion in 'Microcontrollers' started by aldrinsi, Jul 17, 2009.

  1. aldrinsi

    aldrinsi New Member

    Joined:
    Jul 17, 2009
    Messages:
    11
    Likes:
    0
    Location:
    Philippines
    i'm new in microcontroller, and i'm using PIC16F84A. Can somebody please tell me what's wrong with my program, i just wish to set portA and portB as output and illuminate LED which will be connected to the ports.

    #INCLUDE P16F84A.INC

    __config _XT_OSC & _CP_OFF & _PWRTE_OFF & _WDT_OFF

    MOVLW 0x00
    BSF STATUS, RP0
    MOVWF TRISA
    MOVWF TRISB
    BCF STATUS, RP0
    MOVLW 0xFF
    MOVWF PORTA
    MOVWF PORTB

    end
    here's the error:
    ----------------------------------------------------------------------
    Release build of project `C:\Documents and Settings\Admin\Desktop\Group8\blinkingLED.mcp' started.
    Fri Jul 17 19:33:37 2009
    ----------------------------------------------------------------------
    Clean: Deleting intermediary and output files.
    Clean: Done.
    Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F84A "blinkingLED.asm" /l"blinkingLED.lst" /e"blinkingLED.err" /o"blinkingLED.o"
    Error[152] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 6 : Executable code and data must be defined in an appropriate section
    Error[152] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 7 : Executable code and data must be defined in an appropriate section
    Message[302] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 8 : Register in operand not in bank 0. Ensure that bank bits are correct.
    Error[152] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 8 : Executable code and data must be defined in an appropriate section
    Message[302] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 9 : Register in operand not in bank 0. Ensure that bank bits are correct.
    Error[152] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 9 : Executable code and data must be defined in an appropriate section
    Error[152] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 10 : Executable code and data must be defined in an appropriate section
    Error[152] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 11 : Executable code and data must be defined in an appropriate section
    Error[152] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 12 : Executable code and data must be defined in an appropriate section
    Error[152] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 13 : Executable code and data must be defined in an appropriate section
    Halting build on first failure as requested.
    ----------------------------------------------------------------------
    Release build of project `C:\Documents and Settings\Admin\Desktop\Group8\blinkingLED.mcp' failed.
    Fri Jul 17 19:33:38 2009
    ----------------------------------------------------------------------
    BUILD FAILED
     
  2. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,541
    Likes:
    174
    Location:
    Toronto, Canada
    Use code tags next time, it preserves formatting.

    Your code must not be in the 1st column.
     
  3. aldrinsi

    aldrinsi New Member

    Joined:
    Jul 17, 2009
    Messages:
    11
    Likes:
    0
    Location:
    Philippines
    pls help..:(

    i already moved my codes to the next column, but still the same result..:(
    what are code tags?can you pls help me debug my program?plsss.....
     
  4. dave miyares

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    2
    Likes:
    -10


     
  5. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,354
    Likes:
    650
    Location:
    Ex Yorks' Hants UK
    Hi,
    Your code reformatted.

    You need to add more information in the header.

    Code (text):


        list      p=16f84A         ; list directive to define processor
        #include <p16F84A.inc>        ; processor specific variable definitions
        errorlevel  -302 , -207             ; suppress message 302 from list file

        __config _XT_OSC & _CP_OFF & _PWRTE_OFF & _WDT_OFF


        ORG     0x00            ; processor reset vector
        goto    main              ; go to beginning of program
       

        ORG     0x004             ; interrupt vector location
        nop
        retfie                    ; return from interrupt

     
    main:
        movlw   0x00
        bsf STATUS, RP0
        movwf   TRISA
        movwf   TRISB
        bcf STATUS, RP0
        movlw   0xFF
        movwf   PORTA
        movwf   PORTB

        end
     
    Last edited: Jul 17, 2009
  6. aldrinsi

    aldrinsi New Member

    Joined:
    Jul 17, 2009
    Messages:
    11
    Likes:
    0
    Location:
    Philippines
    thanks for replying.. but...

    i already reformatted the codes, but still having the same result..:(
    what should i do?is there any solution to resolve my problem?
     
  7. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,541
    Likes:
    174
    Location:
    Toronto, Canada
    Uninstall and reinstall MPLAB
     
  8. dave miyares

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    2
    Likes:
    -10


     
  9. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,354
    Likes:
    650
    Location:
    Ex Yorks' Hants UK
    hi,
    Did you copy the edited version of the program I posted, showing the Headers.???
     
  10. aldrinsi

    aldrinsi New Member

    Joined:
    Jul 17, 2009
    Messages:
    11
    Likes:
    0
    Location:
    Philippines
    Yes, i already copied and pasted it on MPLAB, still, it didn't work... :(
     
  11. aldrinsi

    aldrinsi New Member

    Joined:
    Jul 17, 2009
    Messages:
    11
    Likes:
    0
    Location:
    Philippines
    s0 sorry... thank u s0 much!!:D

    ----------------------------------------------------------------------
    Release build of project `C:\Documents and Settings\Admin\Desktop\Group8\blinkingLED.mcp' started.
    Fri Jul 17 20:12:07 2009
    ----------------------------------------------------------------------
    Clean: Deleting intermediary and output files.
    Clean: Done.
    Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F84A "blinkingLED.asm" /l"blinkingLED.lst" /e"blinkingLED.err" /o"blinkingLED.o"
    Warning[205] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\GROUP8\BLINKINGLED.ASM 1 : Found directive in column 1. (list)
    Executing: "C:\Program Files\Microchip\MPASM Suite\mplink.exe" /p16F84A "blinkingLED.o" /z__MPLAB_BUILD=1 /o"blinkingLED.cof" /M"blinkingLED.map" /W
    MPLINK 4.30.01, Linker
    Copyright (c) 2009 Microchip Technology Inc.
    Errors : 0

    MP2HEX 4.30.01, COFF to HEX File Converter
    Copyright (c) 2009 Microchip Technology Inc.
    Errors : 0

    Loaded C:\Documents and Settings\Admin\Desktop\Group8\blinkingLED.cof.
    ----------------------------------------------------------------------
    Release build of project `C:\Documents and Settings\Admin\Desktop\Group8\blinkingLED.mcp' succeeded.
    Fri Jul 17 20:12:08 2009
    ----------------------------------------------------------------------
    BUILD SUCCEEDED


    it really works!!your d best man!!:) thank you s0 much!!!!by the way, do i really need to type those headers everytime i try to create a program?
     
  12. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,354
    Likes:
    650
    Location:
    Ex Yorks' Hants UK
    hi,
    Modified your program to flash the PORTA and B , on/off once per second.

    It does work in Oshonsoft Sim OK.?


    Code (text):

        list      p=16f84A         ; list directive to define processor
        #include <p16F84A.inc>        ; processor specific variable definitions
        errorlevel  -302 , -207             ; suppress message 302 from list file

        __config _XT_OSC & _CP_OFF & _PWRTE_OFF & _WDT_OFF

       
    d1      equ 0x20
    d2  equ 0x21
    d3  equ 0x22


        ORG     0x00            ; processor reset vector
        goto    main              ; go to beginning of program
       

        ORG     0x004             ; interrupt vector location
        nop
        retfie                    ; return from interrupt

     
    main:
        movlw   0x00
        bsf STATUS, RP0
        movwf   TRISA
        movwf   TRISB
        bcf STATUS, RP0

    loop1:
        movlw   0xFF
        movwf   PORTA
        movwf   PORTB
       
        call Delay
       
        movlw   0x00
        movwf   PORTA
        movwf   PORTB

        call Delay

        goto loop1

    Delay:
                ;999997 cycles
        movlw   0x08
        movwf   d1
        movlw   0x2F
        movwf   d2
        movlw   0x03
        movwf   d3
    Delay_0
        decfsz  d1, f
        goto    $+2
        decfsz  d2, f
        goto    $+2
        decfsz  d3, f
        goto    Delay_0
                ;3 cycles
        goto    $+1
        return

        end
    The header detail is VITAL in order for MPLAB to assemble your programs.

    Make the Header part a text file, which you copy and paste.
    NOTE: different PIC types require different Headers.

    EDIT:
    if you connect LED's to the PIC pins, use a low value resistor in series with the LED, say 330 ohms
     
    Last edited: Jul 17, 2009
  13. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,541
    Likes:
    174
    Location:
    Toronto, Canada
    Did you run the MPLAB wizard?
     
  14. aldrinsi

    aldrinsi New Member

    Joined:
    Jul 17, 2009
    Messages:
    11
    Likes:
    0
    Location:
    Philippines
    Micro-wizard

    w0w!!your a master!!hahaha!i just finished testing the result of the program that u gave me, its amazing!hahaha!i've really learned a lot from you!!thank you so much!!:)
     
  15. wael_sal

    wael_sal New Member

    Joined:
    Oct 31, 2006
    Messages:
    16
    Likes:
    0

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice