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

"Link Step Failed" in MPLAB v8.43

Discussion in 'Microcontrollers' started by swapan, Feb 18, 2014.

  1. swapan

    swapan Member

    Joined:
    Aug 29, 2009
    Messages:
    72
    Likes:
    0
    Location:
    KOLKATA (INDIA)
    Hi Friends,

    With the help of this forum and going through various tutorials in the internet I have managed to make a moving message display using MCU 16F72 and shift register 74HC595. The project works. But since the MCU has only 2K of Program Memory, thought to use 16F886 to have a longer message displayed. When I compiled the code and tried to build, an error message was shown like this -

    "Error - section 'MAIN_PROG' can not fit the section. Section 'MAIN_PROG' length=0x00001020
    Errors : 1

    Link step failed.
    "

    However, if the data of message to be displayed is reduced, say 2024 byte, the code builds successfully.

    I cannot make out what does this error mean. Practically it is seen that both the MCUs can handle same amount of message data though 16F886 has a program memory capacity of 8K and data memory of 368 byte whereas 16F72 has only 2k of program memory and 128 byte of data memory.

    The code is given. Please forgive for not giving the comment.

    Would you kindly help me in this matter?

    swapan
    Code (text):
    ;**********************************************************************
    ;                                                                     *
    ;    Files required: P16F886.INC                                      *
    ;                                                                     *
    ;                                                                     *
    ;                                                                     *
    ;**********************************************************************
    ;                                                                     *
    ;    Notes:                                                           *
    ;                                                                     *
    ;                                                                     *
    ;                                                                     *
    ;                                                                     *
    ;**********************************************************************

        list        p=16f886    ; list directive to define processor
        #include    <p16f886.inc>   ; processor specific variable definitions

    ; '__CONFIG' directive is used to embed configuration data within .asm file.
    ; The labels following the directive are located in the respective .inc file.
    ; See respective data sheet for additional information on configuration word.

        __CONFIG    _CONFIG1, _LVP_OFF & _FCMEN_ON & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_ON & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
        __CONFIG    _CONFIG2, _WRT_OFF & _BOR21V

    ;***** VARIABLE DEFINITIONS (examples)
    cblock            0x20
    col_count                         ; variable used for context saving
    view_count
    mask
    ptrl
    ptrh
    count1
    count2
    row_count
    bit_count
    temp_ptrl
    temp_ptrh
    endc

    #define Serial_Data  PORTB,4;
    #define SH_Clk  PORTB,6;
    #define  ST_Clk  PORTB,7;
    #define row_data  PORTC,3;
    #define  clear  PORTC,2;
    #define  clk PORTC,1;

    ; example of using Shared Uninitialized Data Section
    INT_VAR     UDATA_SHR  
    w_temp      RES     1       ; variable used for context saving
    status_temp RES     1       ; variable used for context saving
    pclath_temp RES     1       ; variable used for context saving

    ; example of using Uninitialized Data Section
    TEMP_VAR    UDATA           ; explicit address specified is not required
    temp_count  RES     1       ; temporary variable (example)

    ;**********************************************************************
    RESET_VECTOR    CODE    0x0000 ; processor reset vector
        nop
        goto    start              ; go to beginning of program

    INT_VECTOR      CODE    0x0004 ; interrupt vector location

    INTERRUPT

        movwf   w_temp          ; save off current W register contents
        movf    STATUS,w        ; move status register into W register
        movwf   status_temp     ; save off contents of STATUS register
        movf    PCLATH,w        ; move pclath register into w register
        movwf   pclath_temp     ; save off contents of PCLATH register

    ; isr code can go here or be located as a call subroutine elsewhere

        movf    pclath_temp,w       ; retrieve copy of PCLATH register
        movwf   PCLATH          ; restore pre-isr PCLATH register contents
        movf    status_temp,w       ; retrieve copy of STATUS register
        movwf   STATUS          ; restore pre-isr STATUS register contents
        swapf   w_temp,f
        swapf   w_temp,w        ; restore pre-isr W register contents
        retfie              ; return from interrupt

    MAIN_PROG       CODE

    start

    bsf        STATUS,RP0
    movlw        00h
    movwf        TRISA
    movlw        00h
    movwf        TRISB
    movlw        00h
    movwf        TRISC
    movlw        06h
    movwf        ADCON1
    movlw        b'10000111'
    movwf        OPTION_REG
    ;bsf        STATUS,RP1
    ;bsf        STATUS,IRP
    ;movlw    b'00000000'
    ;movwf    ANSEL
    ;movlw    b'00000000'
    ;movwf    ANSELH
    bcf        STATUS,RP0
    ;bcf        STATUS,RP1
    ;bcf        STATUS,IRP  
    ;;;;;;;;;;;

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    movlw   high(table)     ; table address hi
    movwf   ptrh            ;
    movlw   low(table)      ; table address lo
    movwf   ptrl            ; ptrh:l = &table[0]

    initial_run:
    movlw    d'5'
    movwf    view_count



    Run_1:

    movf    ptrh,W          ;  
    movwf    temp_ptrh
    movf    ptrl,w
    movwf    temp_ptrl
    movlw    d'1'
    movwf    mask
    movlw    d'96'
    movwf    col_count
    movlw    d'8'
    movwf    row_count
    movlw    d'8'
    movwf    bit_count

    bcf        clear
    nop
    bsf        clear
    bsf        row_data


    Run_2:
    call    read_table
    goto    data_feed


    data_feed:
    andwf    mask,w
    btfsc    status,z
    goto    low_data
    goto    high_data


    low_data:
    bcf   serial_data
    bsf        SH_Clk
    nop
    bcf        SH_Clk
    decfsz    col_count,1
    goto    next_col
    bsf        clk
    nop
    bcf        clk
    bcf        row_data
    bsf        ST_Clk
    nop
    bcf        ST_Clk
    call    view_delay
    decfsz    bit_count,1
    goto    next_row
    goto    second_set



    high_data:
    bsf   serial_data
    bsf        SH_Clk
    nop
    bcf        SH_Clk
    decfsz    col_count,1
    goto    next_col
    bsf        clk
    nop
    bcf        clk
    bcf        row_data
    bsf        ST_Clk
    nop
    bcf        ST_Clk
    call    view_delay
    decfsz    bit_count,1
    goto    next_row
    goto    second_set

    next_col:
    incf                temp_ptrl,f
    skpnz      
    incf                temp_ptrh,f
    incf                temp_ptrl,f
    skpnz      
    incf                temp_ptrh,f
    goto    Run_2





    next_row:
    decfsz    row_count,1
    goto    row_scan
    goto    second_set

    row_scan:
    rlf        mask,1
    movf    ptrh,W          ;  
    movwf    temp_ptrh
    movf    ptrl,w
    movwf    temp_ptrl
    movlw    d'96'
    movwf    col_count
    goto    Run_2




    second_set:
    movf    ptrh,W          ;  
    movwf    temp_ptrh
    movf    ptrl,w
    movwf    temp_ptrl
    movlw    d'1';
    movwf    mask
    movlw    d'96'
    movwf    col_count
    movlw    d'8'
    movwf    row_count
    movlw    d'8'
    movwf    bit_count
    incf                temp_ptrl,f
    skpnz      
    incf                temp_ptrh,f
    goto    Run_3


    Run_3:
    call    read_table
    goto    data_feed_1  



    data_feed_1:
    andwf    mask,w
    btfsc    status,z
    goto    low_data_1
    goto    high_data_1


    low_data_1:
    bcf   serial_data
    bsf        SH_Clk
    nop
    bcf        SH_Clk
    decfsz    col_count,1
    goto    next_col_1
    bsf        clk
    nop
    bcf        clk
    bcf        row_data
    bsf        ST_Clk
    nop
    bcf        ST_Clk
    call    view_delay

    decfsz    bit_count,1
    goto    next_row_1

    decfsz    view_count,1
    goto    Run_1
    incf    ptrl,f
    skpnz
    incf    ptrh,f

    incf    ptrl,f
    skpnz
    incf    ptrh,f
    movlw    d'5'
    movwf    view_count
    goto    Run_1


    high_data_1:
    bsf   serial_data
    bsf        SH_Clk
    nop
    bcf        SH_Clk
    decfsz    col_count,1
    goto    next_col_1
    bsf        clk
    nop
    bcf        clk
    bcf        row_data
    bsf        ST_Clk
    nop
    bcf        ST_Clk

    call    view_delay
    decfsz    bit_count,1
    goto    next_row_1

    decfsz    view_count,1
    goto    Run_1
    incf    ptrl,f
    skpnz
    incf    ptrh,f

    incf    ptrl,f
    skpnz
    incf    ptrh,f
    movlw    d'5'
    movwf    view_count
    goto    Run_1


    next_col_1:
    incf                temp_ptrl,f
    skpnz      
    incf                temp_ptrh,f
    incf                temp_ptrl,f
    skpnz      
    incf                temp_ptrh,f
    goto    Run_3

    next_row_1:
    decfsz    row_count,1
    goto    row_scan_1
    goto    second_set

    row_scan_1:
    rlf        mask,1
    movf    ptrh,W          ;  
    movwf    temp_ptrh
    movf    ptrl,w
    movwf    temp_ptrl
    incf                temp_ptrl,f
    skpnz      
    incf                temp_ptrh,f
    movlw    d'96'
    movwf    col_count
    goto    Run_3


    view_delay:
    movlw    d'2'
    movwf    count1
    movlw    d'255'
    movwf    count2
    decfsz    count2,1
    goto    $-1
    decfsz    count1,1
    goto    $-5
    return

    ;*************************************************************

    read_table:
    movf    temp_ptrh,w
    movwf   PCLATH          ;  
    movf    temp_ptrl,W          ;  
    movwf   PCL
    table

    dt    00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,
    dt    00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,
    dt    00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,
    dt    00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,
    dt    00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,


    ;N
    dt 0FFh,0FFh,0FFh,0FFh,000h,038h,000h,070h,000h,0E0h,001h,0C0h,003h,080h,007h,000h,00Eh,000h,01Ch,000h,0FFh,0FFh,0FFh,0FFh,000h,000h,000h,000h,
    ;A
    dt 0FFh,0E0h,0FFh,0F0h,006h,038h,006h,01Ch,006h,00Eh,006h,007h,006h,007h,006h,00Eh,006h,01Ch,006h,038h,0FFh,0F0h,0FFh,0E0h,000h,000h,000h,000h,
    ;N
    dt 0FFh,0FFh,0FFh,0FFh,000h,038h,000h,070h,000h,0E0h,001h,0C0h,003h,080h,007h,000h,00Eh,000h,01Ch,000h,0FFh,0FFh,0FFh,0FFh,000h,000h,000h,000h,
    ;D
    dt 0FFh,0FFh,0FFh,0FFh,0C0h,003h,0C0h,003h,0C0h,003h,0C0h,003h,0C0h,003h,0C0h,003h,0E0h,007h,070h,00Eh,03Fh,0FCh,01Fh,0F8h,000h,000h,000h,000h,
    ;I
    dt 0FFh,0FFh,0FFh,0FFh,000h,000h,000h,000h,
    ;SPACE
    dt    00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,
        END                       ; directive 'end of program'
     

Share This Page