Sida 1 av 1

Förstår inte detta link fel

Postat: 17 november 2011, 10:59:17
av jfri
Nedanstående program (relocatable kod) för en 18F458 ger följande felmeddelande av MPLAB
MPLINK 4.40, Linker
Device Database Version 1.0
Copyright (c) 1998-2011 Microchip Technology Inc.
Error - file './sinusgen.o', section 'START', Symbol '_START_0038' is not word-aligned.
It can not be used as the target of a call or goto instruction.
Errors : 1

I MPLABX ännu mer kryptiskt

C:\\Program\ Files\ \(x86\)\\Microchip\\MPLABX\\mpasmx\\mplink.exe -p18f458 -w -z__MPLAB_BUILD=1 -odist/default/production/sinusgenerator.X.production.cof build/default/production/sinusgen.o
make[2]: *** [dist/default/production/sinusgenerator.X.production.cof] Error 1
MPLINK 4.40, Linker
Device Database Version 1.2
make[1]: *** [.build-conf] Error 2
Copyright (c) 1998-2011 Microchip Technology Inc.
make: *** [.build-impl] Error 2
Error - file './build/default/production/sinusgen.o', section 'START', Symbol '_START_0018' is not word-aligned.
It can not be used as the target of a call or goto instruction.
Errors : 1

Programmet

Kod: Markera allt

list p=18f458
 #include p18f458.inc
 config WDT=OFF, OSC=HS, LVP=Off, WDTPS = 128
Rst    CODE   0x00
    goto    start
START   CODE 0x20
start
    Call    Initiering
    movlw   'A'
mainloop
    nop
    Call    Printchar
    goto    mainloop

Printchar
    bsf     TXSTA,TXEN,0
    movwf   TXREG
    nop
    btfsc   PIR1,TXIF
    goto    $-1
    return

Initiering
    BANKSEL PORTC
    clrf    PORTC           ;Clear output data latches
    BANKSEL TRISC
    movlw   b'10000000'     ;Config RC7 RS as input for USART use
    movwf   TRISC
    BANKSEL PORTC
    movlw   b'00001000'     ;Tänd LED
    movwf   PORTC
    BANKSEL ADCON1
    movlw   b'10000000'     ;Right justified result
    movwf   ADCON1          ;Konfigurera alla AD pinnar till analoga
    BANKSEL ADCON0
    movlw   b'00111001'     ;Select AN7 ADC On
    movwf   ADCON0
    BANKSEL CMCON
    movwf   CMCON           ;Comparator off
    BANKSEL TRISD
    movlw   b'00000000'     ;Hela Port D utgång till DA
    movwf   TRISD
    BANKSEL TRISE
    movlw   b'00000100'     ;RE2 används som ADC
    movwf   TRISE
    ;USART
    movlw   b'10000000'
    movwf   RCSTA           ;Enable serial port
    movlw   b'00000110'
    movwf   TXSTA           ;BRGH=1 SYNC=0
    movlw   2
    movwf   SPBRG           ;for 115200 baud
    return
 END

Re: Förstår inte detta link fel

Postat: 17 november 2011, 11:50:24
av sodjan
Ändra "goto $-1" till "goto $-2".

Eller bättre, ändra :

Kod: Markera allt

    btfsc       PIR1,TXIF
    goto        $-2
till:

Kod: Markera allt

txif_loop
    btfsc       PIR1,TXIF
    goto        txif_loop
Då fungerar samma kod på både PIC16 och PIC18...