构建错误“make:*** [.build-impl]错误2”

发布于 2025-01-17 11:40:13 字数 9465 浏览 3 评论 0原文

我有一个简单的代码,用于我的MicroControllerSteacher要求的初始项目。

IM使用Mplab IDE V6.00,XC8编译器。

但是,当我尝试清洁并构建它时,会出现红色煤层代码(最后5行):

CLEAN SUCCESSFUL (total time5ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'D:/luis/Documents/Curso/Micro/trab1_micro.X'
make  -f nbproject/Makefile-default.mk dist/default/production/trab1_micro.X.production.hex
make[2]: Entering directory 'D:/luis/Documents/Curso/Micro/trab1_micro.X'
"C:\Program Files\Microchip\xc8\v2.36\bin\xc8-cc.exe" -c  -mcpu=16F887   -mdfp="C:/Program Files/Microchip/MPLABX/v6.00/packs/Microchip/PIC16Fxxx_DFP/1.3.42/xc8"  -fno-short-double -fno-short-float -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default  -msummary=-psect,-class,+mem,-hex,-file  -ginhx32 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto   -o build/default/production/newAsmTemplate.o  newAsmTemplate.asm 
::: advisory: (2049) C99 compliant libraries are currently not available for baseline or mid-range devices, or for enhanced mid-range devices using a reentrant stack; using C90 libraries
newAsmTemplate.asm:34:25: warning: extra tokens at end of #include directive [-Wextra-tokens]
        #include        <p16f887.inc>   ; processor specific variable definitions
                                        ^
                                        //
newAsmTemplate.asm:34:11: fatal error: 'p16f887.inc' file not found
        #include        <p16f887.inc>   ; processor specific variable definitions
                        ^~~~~~~~~~~~~
1 warning and 1 error generated.
(908) exit status = 1
nbproject/Makefile-default.mk:113: recipe for target 'build/default/production/newAsmTemplate.o' failed
make[2]: Leaving directory 'D:/luis/Documents/Curso/Micro/trab1_micro.X'
nbproject/Makefile-default.mk:91: recipe for target '.build-conf' failed
make[1]: Leaving directory 'D:/luis/Documents/Curso/Micro/trab1_micro.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[2]: *** [build/default/production/newAsmTemplate.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 1s)

这是我为PIC项目制作的代码。

汇编代码在这里有帮助:

;**********************************************************************
;   This file is a basic code template for assembly code generation   *
;   on the PIC16F887. This file contains the basic code               *
;   building blocks to build upon.                                    *
;                                                                     *
;   Refer to the MPASM User's Guide for additional information on     *
;   features of the assembler (Document DS33014).                     *
;                                                                     *
;   Refer to the respective PIC data sheet for additional             *
;   information on the instruction set.                               *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Filename:      pic.asm                                           *
;    Date:                                                            *
;    File Version:                                                    *
;                                                                     *
;    Author:                                                          *
;    Company:                                                         *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files Required: P16F887.INC                                      *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Notes:                                                           *
;                                                                     *
;**********************************************************************


    list        p=16f887    ; list directive to define processor
    #include    <p16f887.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
DISPLAY_U       EQU     0X7A
DISPLAY_D       EQU     0X7B
VAR     EQU 0x7C
w_temp      EQU 0x7D        ; variable used for context saving
status_temp EQU 0x7E        ; variable used for context saving
pclath_temp EQU 0x7F        ; variable used for context saving


;**********************************************************************
    ORG     0x000             ; processor reset vector

    nop
    goto    main              ; go to beginning of program


    ORG     0x004             ; interrupt vector location

    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
    
    btfss   PIR1, ADIF
    goto    AD_INT_FIM
    bcf PIR1, ADIF
    rrf ADRESH, F
    bcf     ADRESH, 1; 7
    movf    ADRESH, W
    call    TABELA
    movwf   VAR
    sublw   b'00100101'      ;25 em bcd, respetivo aos 2.5V
    btfss   STATUS, Z        ;flag z, testar se ativou
    goto    AD_INT_FIM
    movlw   b'00111001'      ;39 em bcd, respetivo aos nossos números de alunos
    movwf   VAR
    
    
AD_INT_FIM
    
    btfss   INTCON, INTF
    goto    FIM_INT
    bcf     INTCON, INTF
    bsf     ADCON0, GO
    
    FIM_INT

    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
    bsf STATUS,RP1
    bsf STATUS,RP0
    bsf ANSEL, ANS0
    bcf     ANSELH, ANS12
    
    bcf STATUS,RP1
    bsf STATUS,RP0
    clrf    TRISC
    bsf PIE1, ADIE
    
    bcf STATUS, RP0
    movlw   b'00000001'
    movwf   ADCON0
    bcf PIR1, ADIF
    bsf INTCON, INTE
    bcf INTCON, INTF
    bsf INTCON, PEIE
    bsf INTCON, GIE
    
    clrf    VAR
loop
    ;  VAR = U U U U  D D D D 
    ;PORTC = 1 0 X X  D D D D
    movf    VAR, W
    movwf   DISPLAY_D
    bsf     DISPLAY_D, 1; 7
    bcf     DISPLAY_D, 0; 6
    movf    DISPLAY_D, W
    movwf   PORTC
    
    ;PORTC = 0 1 X X  U U U U
    movf    VAR, W
    movwf   DISPLAY_U
    swapf   DISPLAY_U, F
    bcf     DISPLAY_U, 1; 7
    bsf     DISPLAY_U, 0; 6
    movf    DISPLAY_U, W
    movwf   PORTC
    
    GOTO loop

; remaining code goes here

TABELA
addwf PCL,f 
RETLW 0x0
RETLW 0x0
RETLW 0x1
RETLW 0x1
RETLW 0x2
RETLW 0x2
RETLW 0x2
RETLW 0x3
RETLW 0x3
RETLW 0x4
RETLW 0x4
RETLW 0x4
RETLW 0x5
RETLW 0x5
RETLW 0x5
RETLW 0x6
RETLW 0x6
RETLW 0x7
RETLW 0x7
RETLW 0x7
RETLW 0x8
RETLW 0x8
RETLW 0x9
RETLW 0x9
RETLW 0x9
RETLW 0x10
RETLW 0x10
RETLW 0x11
RETLW 0x11
RETLW 0x11
RETLW 0x12
RETLW 0x12
RETLW 0x13
RETLW 0x13
RETLW 0x13
RETLW 0x14
RETLW 0x14
RETLW 0x14
RETLW 0x15
RETLW 0x15
RETLW 0x16
RETLW 0x16
RETLW 0x16
RETLW 0x17
RETLW 0x17
RETLW 0x18
RETLW 0x18
RETLW 0x18
RETLW 0x19
RETLW 0x19
RETLW 0x20
RETLW 0x20
RETLW 0x20
RETLW 0x21
RETLW 0x21
RETLW 0x21
RETLW 0x22
RETLW 0x22
RETLW 0x23
RETLW 0x23
RETLW 0x23
RETLW 0x24
RETLW 0x24
RETLW 0x25
RETLW 0x25
RETLW 0x25
RETLW 0x26
RETLW 0x26
RETLW 0x27
RETLW 0x27
RETLW 0x27
RETLW 0x28
RETLW 0x28
RETLW 0x29
RETLW 0x29
RETLW 0x29
RETLW 0x30
RETLW 0x30
RETLW 0x30
RETLW 0x31
RETLW 0x31
RETLW 0x32
RETLW 0x32
RETLW 0x32
RETLW 0x33
RETLW 0x33
RETLW 0x34
RETLW 0x34
RETLW 0x34
RETLW 0x35
RETLW 0x35
RETLW 0x36
RETLW 0x36
RETLW 0x36
RETLW 0x37
RETLW 0x37
RETLW 0x38
RETLW 0x38
RETLW 0x38
RETLW 0x39
RETLW 0x39
RETLW 0x39
RETLW 0x40
RETLW 0x40
RETLW 0x41
RETLW 0x41
RETLW 0x41
RETLW 0x42
RETLW 0x42
RETLW 0x43
RETLW 0x43
RETLW 0x43
RETLW 0x44
RETLW 0x44
RETLW 0x45
RETLW 0x45
RETLW 0x45
RETLW 0x46
RETLW 0x46
RETLW 0x46
RETLW 0x47
RETLW 0x47
RETLW 0x48
RETLW 0x48
RETLW 0x48
RETLW 0x49
RETLW 0x49
RETLW 0x50


; example of preloading EEPROM locations
    ORG 0x2100
    DE  5, 4, 3, 2, 1

    END                       ; directive 'end of program'

I have this simple code for an initial project that my microcontrollersteacher asked.

Im using MPLAB IDE V6.00, the xc8 compiler.

But when i try to clean and build it this error in red collor code appears (the last 5 lines):

CLEAN SUCCESSFUL (total time5ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'D:/luis/Documents/Curso/Micro/trab1_micro.X'
make  -f nbproject/Makefile-default.mk dist/default/production/trab1_micro.X.production.hex
make[2]: Entering directory 'D:/luis/Documents/Curso/Micro/trab1_micro.X'
"C:\Program Files\Microchip\xc8\v2.36\bin\xc8-cc.exe" -c  -mcpu=16F887   -mdfp="C:/Program Files/Microchip/MPLABX/v6.00/packs/Microchip/PIC16Fxxx_DFP/1.3.42/xc8"  -fno-short-double -fno-short-float -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default  -msummary=-psect,-class,+mem,-hex,-file  -ginhx32 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto   -o build/default/production/newAsmTemplate.o  newAsmTemplate.asm 
::: advisory: (2049) C99 compliant libraries are currently not available for baseline or mid-range devices, or for enhanced mid-range devices using a reentrant stack; using C90 libraries
newAsmTemplate.asm:34:25: warning: extra tokens at end of #include directive [-Wextra-tokens]
        #include        <p16f887.inc>   ; processor specific variable definitions
                                        ^
                                        //
newAsmTemplate.asm:34:11: fatal error: 'p16f887.inc' file not found
        #include        <p16f887.inc>   ; processor specific variable definitions
                        ^~~~~~~~~~~~~
1 warning and 1 error generated.
(908) exit status = 1
nbproject/Makefile-default.mk:113: recipe for target 'build/default/production/newAsmTemplate.o' failed
make[2]: Leaving directory 'D:/luis/Documents/Curso/Micro/trab1_micro.X'
nbproject/Makefile-default.mk:91: recipe for target '.build-conf' failed
make[1]: Leaving directory 'D:/luis/Documents/Curso/Micro/trab1_micro.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[2]: *** [build/default/production/newAsmTemplate.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 1s)

Here is code i made for the pic project.

The assembly code is here in case it helps:

;**********************************************************************
;   This file is a basic code template for assembly code generation   *
;   on the PIC16F887. This file contains the basic code               *
;   building blocks to build upon.                                    *
;                                                                     *
;   Refer to the MPASM User's Guide for additional information on     *
;   features of the assembler (Document DS33014).                     *
;                                                                     *
;   Refer to the respective PIC data sheet for additional             *
;   information on the instruction set.                               *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Filename:      pic.asm                                           *
;    Date:                                                            *
;    File Version:                                                    *
;                                                                     *
;    Author:                                                          *
;    Company:                                                         *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files Required: P16F887.INC                                      *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Notes:                                                           *
;                                                                     *
;**********************************************************************


    list        p=16f887    ; list directive to define processor
    #include    <p16f887.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
DISPLAY_U       EQU     0X7A
DISPLAY_D       EQU     0X7B
VAR     EQU 0x7C
w_temp      EQU 0x7D        ; variable used for context saving
status_temp EQU 0x7E        ; variable used for context saving
pclath_temp EQU 0x7F        ; variable used for context saving


;**********************************************************************
    ORG     0x000             ; processor reset vector

    nop
    goto    main              ; go to beginning of program


    ORG     0x004             ; interrupt vector location

    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
    
    btfss   PIR1, ADIF
    goto    AD_INT_FIM
    bcf PIR1, ADIF
    rrf ADRESH, F
    bcf     ADRESH, 1; 7
    movf    ADRESH, W
    call    TABELA
    movwf   VAR
    sublw   b'00100101'      ;25 em bcd, respetivo aos 2.5V
    btfss   STATUS, Z        ;flag z, testar se ativou
    goto    AD_INT_FIM
    movlw   b'00111001'      ;39 em bcd, respetivo aos nossos números de alunos
    movwf   VAR
    
    
AD_INT_FIM
    
    btfss   INTCON, INTF
    goto    FIM_INT
    bcf     INTCON, INTF
    bsf     ADCON0, GO
    
    FIM_INT

    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
    bsf STATUS,RP1
    bsf STATUS,RP0
    bsf ANSEL, ANS0
    bcf     ANSELH, ANS12
    
    bcf STATUS,RP1
    bsf STATUS,RP0
    clrf    TRISC
    bsf PIE1, ADIE
    
    bcf STATUS, RP0
    movlw   b'00000001'
    movwf   ADCON0
    bcf PIR1, ADIF
    bsf INTCON, INTE
    bcf INTCON, INTF
    bsf INTCON, PEIE
    bsf INTCON, GIE
    
    clrf    VAR
loop
    ;  VAR = U U U U  D D D D 
    ;PORTC = 1 0 X X  D D D D
    movf    VAR, W
    movwf   DISPLAY_D
    bsf     DISPLAY_D, 1; 7
    bcf     DISPLAY_D, 0; 6
    movf    DISPLAY_D, W
    movwf   PORTC
    
    ;PORTC = 0 1 X X  U U U U
    movf    VAR, W
    movwf   DISPLAY_U
    swapf   DISPLAY_U, F
    bcf     DISPLAY_U, 1; 7
    bsf     DISPLAY_U, 0; 6
    movf    DISPLAY_U, W
    movwf   PORTC
    
    GOTO loop

; remaining code goes here

TABELA
addwf PCL,f 
RETLW 0x0
RETLW 0x0
RETLW 0x1
RETLW 0x1
RETLW 0x2
RETLW 0x2
RETLW 0x2
RETLW 0x3
RETLW 0x3
RETLW 0x4
RETLW 0x4
RETLW 0x4
RETLW 0x5
RETLW 0x5
RETLW 0x5
RETLW 0x6
RETLW 0x6
RETLW 0x7
RETLW 0x7
RETLW 0x7
RETLW 0x8
RETLW 0x8
RETLW 0x9
RETLW 0x9
RETLW 0x9
RETLW 0x10
RETLW 0x10
RETLW 0x11
RETLW 0x11
RETLW 0x11
RETLW 0x12
RETLW 0x12
RETLW 0x13
RETLW 0x13
RETLW 0x13
RETLW 0x14
RETLW 0x14
RETLW 0x14
RETLW 0x15
RETLW 0x15
RETLW 0x16
RETLW 0x16
RETLW 0x16
RETLW 0x17
RETLW 0x17
RETLW 0x18
RETLW 0x18
RETLW 0x18
RETLW 0x19
RETLW 0x19
RETLW 0x20
RETLW 0x20
RETLW 0x20
RETLW 0x21
RETLW 0x21
RETLW 0x21
RETLW 0x22
RETLW 0x22
RETLW 0x23
RETLW 0x23
RETLW 0x23
RETLW 0x24
RETLW 0x24
RETLW 0x25
RETLW 0x25
RETLW 0x25
RETLW 0x26
RETLW 0x26
RETLW 0x27
RETLW 0x27
RETLW 0x27
RETLW 0x28
RETLW 0x28
RETLW 0x29
RETLW 0x29
RETLW 0x29
RETLW 0x30
RETLW 0x30
RETLW 0x30
RETLW 0x31
RETLW 0x31
RETLW 0x32
RETLW 0x32
RETLW 0x32
RETLW 0x33
RETLW 0x33
RETLW 0x34
RETLW 0x34
RETLW 0x34
RETLW 0x35
RETLW 0x35
RETLW 0x36
RETLW 0x36
RETLW 0x36
RETLW 0x37
RETLW 0x37
RETLW 0x38
RETLW 0x38
RETLW 0x38
RETLW 0x39
RETLW 0x39
RETLW 0x39
RETLW 0x40
RETLW 0x40
RETLW 0x41
RETLW 0x41
RETLW 0x41
RETLW 0x42
RETLW 0x42
RETLW 0x43
RETLW 0x43
RETLW 0x43
RETLW 0x44
RETLW 0x44
RETLW 0x45
RETLW 0x45
RETLW 0x45
RETLW 0x46
RETLW 0x46
RETLW 0x46
RETLW 0x47
RETLW 0x47
RETLW 0x48
RETLW 0x48
RETLW 0x48
RETLW 0x49
RETLW 0x49
RETLW 0x50


; example of preloading EEPROM locations
    ORG 0x2100
    DE  5, 4, 3, 2, 1

    END                       ; directive 'end of program'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只有一腔孤勇 2025-01-24 11:40:13

Microchip 汇编器对文件扩展名可能非常挑剔。使用大写“S”而不是“.asm”引起的问题最少。

这是使用 pic-as 汇编器移植来构建的代码:

;
; File:     pic.S
; Target:   PIC16F887
; Author:   dan1138
; Date:     2022-03-31
; Compiler: pic-as(v2.35)
; IDE:      MPLABX v6.00
;
; Add this line in the project properties box,pic-as Global Options -> Additional options:
;   -Wa,-a -Wl,-pPor_Vec=0h,-pIsr_Vec=4h,-pedata=2100h
;
    PROCESSOR   16F887
    PAGEWIDTH   132
    RADIX       DEC
;**********************************************************************
;   This file is a basic code template for assembly code generation   *
;   on the PIC16F887. This file contains the basic code               *
;   building blocks to build upon.                                    *
;                                                                     *
;   Refer to the MPLAB® XC8 PIC® Assembler User's Guide for mode      *
;   information on features of the assembler (Document DS50002974B).  *
;                                                                     *
;   Refer to the respective PIC data sheet for additional             *
;   information on the instruction set.                               *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Filename:      pic.S                                             *
;    Date:                                                            *
;    File Version:                                                    *
;                                                                     *
;    Author:                                                          *
;    Company:                                                         *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files Required: xc.inc                                           *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Notes:                                                           *
;                                                                     *
;**********************************************************************


#include <xc.inc>


; PIC16F887 Configuration Bit Settings

; Assembly source line config statements

; CONFIG1
  CONFIG  FOSC = INTRC_NOCLKOUT ; Oscillator Selection bits (INTOSCIO oscillator: I/O function on RA6/OSC2/CLKOUT pin,I/O function on RA7/OSC1/CLKIN)
  CONFIG  WDTE = OFF            ; Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
  CONFIG  PWRTE = ON            ; Power-up Timer Enable bit (PWRT enabled)
  CONFIG  MCLRE = ON            ; RE3/MCLR pin function select bit (RE3/MCLR pin function is MCLR)
  CONFIG  CP = OFF              ; Code Protection bit (Program memory code protection is disabled)
  CONFIG  CPD = OFF             ; Data Code Protection bit (Data memory code protection is disabled)
  CONFIG  BOREN = OFF           ; Brown Out Reset Selection bits (BOR disabled)
  CONFIG  IESO = OFF            ; Internal External Switchover bit (Internal/External Switchover mode is disabled)
  CONFIG  FCMEN = ON            ; Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is enabled)
  CONFIG  LVP = OFF             ; Low Voltage Programming Enable bit (RB3 pin has digital I/O,HV on MCLR must be used for programming)

; CONFIG2
  CONFIG  BOR4V = BOR21V        ; Brown-out Reset Selection bit (Brown-out Reset set to 2.1V)
  CONFIG  WRT = OFF             ; Flash Program Memory Self Write Enable bits (Write protection off)

;**********************************************************************
    PSECT   Por_Vec,global,class=CODE,delta=2
    global  resetVec
resetVec:
    PAGESEL main
    goto    main
;
;   Glogal Data space 
    PSECT   Common_Data,global,class=COMMON,space=1,delta=1,noexec
;
    GLOBAL  w_temp,status_temp,pclath_temp
;
DISPLAY_U:      DS      1
DISPLAY_D:      DS      1
VAR:            DS      1
w_temp:         DS      1        ; variable used for context saving
status_temp:    DS      1        ; variable used for context saving
pclath_temp:    DS      1        ; variable used for context saving
;
;   Interrupt vector and handler
    PSECT   Isr_Vec,global,class=CODE,delta=2
    GLOBAL  IsrVec
;
IsrVec:
    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
    
    btfss   PIR1,PIR1_ADIF_POSITION
    goto    AD_INT_FIM
    bcf     PIR1,PIR1_ADIF_POSITION
    rrf     ADRESH,F
    bcf     ADRESH,1       ; 7
    movf    ADRESH,W
    call    TABELA
    movwf   VAR
    sublw   0b00100101      ;25 em bcd,respetivo aos 2.5V
    btfss   STATUS,STATUS_Z_POSITION ;flag z,testar se ativou
    goto    AD_INT_FIM
    movlw   0b00111001      ;39 em bcd,respetivo aos nossos números de alunos
    movwf   VAR
    
    
AD_INT_FIM:
    
    btfss   INTCON,INTCON_INTF_POSITION
    goto    FIM_INT
    bcf     INTCON,INTCON_INTF_POSITION
    bsf     ADCON0,ADCON0_GO_POSITION
    
FIM_INT:

    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 application code
;
    PSECT   MainCode,global,class=CODE,delta=2
main:
    bsf     STATUS,STATUS_RP1_POSITION
    bsf     STATUS,STATUS_RP0_POSITION
    bsf     ANSEL,ANSEL_ANS0_POSITION
    bcf     ANSELH,ANSELH_ANS12_POSITION
    
    bcf     STATUS,STATUS_RP1_POSITION
    bsf     STATUS,STATUS_RP0_POSITION
    clrf    TRISC
    bsf     PIE1,PIE1_ADIE_POSITION
    
    bcf     STATUS,STATUS_RP0_POSITION
    movlw   0b00000001 
    movwf   ADCON0
    bcf     PIR1,PIR1_ADIF_POSITION
    bsf     INTCON,INTCON_INTE_POSITION
    bcf     INTCON,INTCON_INTF_POSITION
    bsf     INTCON,INTCON_PEIE_POSITION
    bsf     INTCON,INTCON_GIE_POSITION
    
    clrf    VAR
loop:
    ;  VAR = U U U U  D D D D 
    ;PORTC = 1 0 X X  D D D D
    movf    VAR,W
    movwf   DISPLAY_D
    bsf     DISPLAY_D,1; 7
    bcf     DISPLAY_D,0; 6
    movf    DISPLAY_D,W
    movwf   PORTC
    
    ;PORTC = 0 1 X X  U U U U
    movf    VAR,W
    movwf   DISPLAY_U
    swapf   DISPLAY_U,F
    bcf     DISPLAY_U,1; 7
    bsf     DISPLAY_U,0; 6
    movf    DISPLAY_U,W
    movwf   PORTC
    
    GOTO loop

; remaining code goes here

TABELA:
    addwf PCL,f 
    RETLW 0x0
    RETLW 0x0
    RETLW 0x1
    RETLW 0x1
    RETLW 0x2
    RETLW 0x2
    RETLW 0x2
    RETLW 0x3
    RETLW 0x3
    RETLW 0x4
    RETLW 0x4
    RETLW 0x4
    RETLW 0x5
    RETLW 0x5
    RETLW 0x5
    RETLW 0x6
    RETLW 0x6
    RETLW 0x7
    RETLW 0x7
    RETLW 0x7
    RETLW 0x8
    RETLW 0x8
    RETLW 0x9
    RETLW 0x9
    RETLW 0x9
    RETLW 0x10
    RETLW 0x10
    RETLW 0x11
    RETLW 0x11
    RETLW 0x11
    RETLW 0x12
    RETLW 0x12
    RETLW 0x13
    RETLW 0x13
    RETLW 0x13
    RETLW 0x14
    RETLW 0x14
    RETLW 0x14
    RETLW 0x15
    RETLW 0x15
    RETLW 0x16
    RETLW 0x16
    RETLW 0x16
    RETLW 0x17
    RETLW 0x17
    RETLW 0x18
    RETLW 0x18
    RETLW 0x18
    RETLW 0x19
    RETLW 0x19
    RETLW 0x20
    RETLW 0x20
    RETLW 0x20
    RETLW 0x21
    RETLW 0x21
    RETLW 0x21
    RETLW 0x22
    RETLW 0x22
    RETLW 0x23
    RETLW 0x23
    RETLW 0x23
    RETLW 0x24
    RETLW 0x24
    RETLW 0x25
    RETLW 0x25
    RETLW 0x25
    RETLW 0x26
    RETLW 0x26
    RETLW 0x27
    RETLW 0x27
    RETLW 0x27
    RETLW 0x28
    RETLW 0x28
    RETLW 0x29
    RETLW 0x29
    RETLW 0x29
    RETLW 0x30
    RETLW 0x30
    RETLW 0x30
    RETLW 0x31
    RETLW 0x31
    RETLW 0x32
    RETLW 0x32
    RETLW 0x32
    RETLW 0x33
    RETLW 0x33
    RETLW 0x34
    RETLW 0x34
    RETLW 0x34
    RETLW 0x35
    RETLW 0x35
    RETLW 0x36
    RETLW 0x36
    RETLW 0x36
    RETLW 0x37
    RETLW 0x37
    RETLW 0x38
    RETLW 0x38
    RETLW 0x38
    RETLW 0x39
    RETLW 0x39
    RETLW 0x39
    RETLW 0x40
    RETLW 0x40
    RETLW 0x41
    RETLW 0x41
    RETLW 0x41
    RETLW 0x42
    RETLW 0x42
    RETLW 0x43
    RETLW 0x43
    RETLW 0x43
    RETLW 0x44
    RETLW 0x44
    RETLW 0x45
    RETLW 0x45
    RETLW 0x45
    RETLW 0x46
    RETLW 0x46
    RETLW 0x46
    RETLW 0x47
    RETLW 0x47
    RETLW 0x48
    RETLW 0x48
    RETLW 0x48
    RETLW 0x49
    RETLW 0x49
    RETLW 0x50


; example of preloading EEPROM locations
    psect   edata,global,class=EEDATA,space=3,delta=2,noexec
    DB  5,4,3,2,1

    END     resetVec            ; directive 'end of program'

The Microchip assembler can be very picky about the file name extension. Using a capital 'S' rather than '.asm' causes the least problems.

This is your code ported to build using the pic-as assembler:

;
; File:     pic.S
; Target:   PIC16F887
; Author:   dan1138
; Date:     2022-03-31
; Compiler: pic-as(v2.35)
; IDE:      MPLABX v6.00
;
; Add this line in the project properties box,pic-as Global Options -> Additional options:
;   -Wa,-a -Wl,-pPor_Vec=0h,-pIsr_Vec=4h,-pedata=2100h
;
    PROCESSOR   16F887
    PAGEWIDTH   132
    RADIX       DEC
;**********************************************************************
;   This file is a basic code template for assembly code generation   *
;   on the PIC16F887. This file contains the basic code               *
;   building blocks to build upon.                                    *
;                                                                     *
;   Refer to the MPLAB® XC8 PIC® Assembler User's Guide for mode      *
;   information on features of the assembler (Document DS50002974B).  *
;                                                                     *
;   Refer to the respective PIC data sheet for additional             *
;   information on the instruction set.                               *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Filename:      pic.S                                             *
;    Date:                                                            *
;    File Version:                                                    *
;                                                                     *
;    Author:                                                          *
;    Company:                                                         *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files Required: xc.inc                                           *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Notes:                                                           *
;                                                                     *
;**********************************************************************


#include <xc.inc>


; PIC16F887 Configuration Bit Settings

; Assembly source line config statements

; CONFIG1
  CONFIG  FOSC = INTRC_NOCLKOUT ; Oscillator Selection bits (INTOSCIO oscillator: I/O function on RA6/OSC2/CLKOUT pin,I/O function on RA7/OSC1/CLKIN)
  CONFIG  WDTE = OFF            ; Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
  CONFIG  PWRTE = ON            ; Power-up Timer Enable bit (PWRT enabled)
  CONFIG  MCLRE = ON            ; RE3/MCLR pin function select bit (RE3/MCLR pin function is MCLR)
  CONFIG  CP = OFF              ; Code Protection bit (Program memory code protection is disabled)
  CONFIG  CPD = OFF             ; Data Code Protection bit (Data memory code protection is disabled)
  CONFIG  BOREN = OFF           ; Brown Out Reset Selection bits (BOR disabled)
  CONFIG  IESO = OFF            ; Internal External Switchover bit (Internal/External Switchover mode is disabled)
  CONFIG  FCMEN = ON            ; Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is enabled)
  CONFIG  LVP = OFF             ; Low Voltage Programming Enable bit (RB3 pin has digital I/O,HV on MCLR must be used for programming)

; CONFIG2
  CONFIG  BOR4V = BOR21V        ; Brown-out Reset Selection bit (Brown-out Reset set to 2.1V)
  CONFIG  WRT = OFF             ; Flash Program Memory Self Write Enable bits (Write protection off)

;**********************************************************************
    PSECT   Por_Vec,global,class=CODE,delta=2
    global  resetVec
resetVec:
    PAGESEL main
    goto    main
;
;   Glogal Data space 
    PSECT   Common_Data,global,class=COMMON,space=1,delta=1,noexec
;
    GLOBAL  w_temp,status_temp,pclath_temp
;
DISPLAY_U:      DS      1
DISPLAY_D:      DS      1
VAR:            DS      1
w_temp:         DS      1        ; variable used for context saving
status_temp:    DS      1        ; variable used for context saving
pclath_temp:    DS      1        ; variable used for context saving
;
;   Interrupt vector and handler
    PSECT   Isr_Vec,global,class=CODE,delta=2
    GLOBAL  IsrVec
;
IsrVec:
    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
    
    btfss   PIR1,PIR1_ADIF_POSITION
    goto    AD_INT_FIM
    bcf     PIR1,PIR1_ADIF_POSITION
    rrf     ADRESH,F
    bcf     ADRESH,1       ; 7
    movf    ADRESH,W
    call    TABELA
    movwf   VAR
    sublw   0b00100101      ;25 em bcd,respetivo aos 2.5V
    btfss   STATUS,STATUS_Z_POSITION ;flag z,testar se ativou
    goto    AD_INT_FIM
    movlw   0b00111001      ;39 em bcd,respetivo aos nossos números de alunos
    movwf   VAR
    
    
AD_INT_FIM:
    
    btfss   INTCON,INTCON_INTF_POSITION
    goto    FIM_INT
    bcf     INTCON,INTCON_INTF_POSITION
    bsf     ADCON0,ADCON0_GO_POSITION
    
FIM_INT:

    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 application code
;
    PSECT   MainCode,global,class=CODE,delta=2
main:
    bsf     STATUS,STATUS_RP1_POSITION
    bsf     STATUS,STATUS_RP0_POSITION
    bsf     ANSEL,ANSEL_ANS0_POSITION
    bcf     ANSELH,ANSELH_ANS12_POSITION
    
    bcf     STATUS,STATUS_RP1_POSITION
    bsf     STATUS,STATUS_RP0_POSITION
    clrf    TRISC
    bsf     PIE1,PIE1_ADIE_POSITION
    
    bcf     STATUS,STATUS_RP0_POSITION
    movlw   0b00000001 
    movwf   ADCON0
    bcf     PIR1,PIR1_ADIF_POSITION
    bsf     INTCON,INTCON_INTE_POSITION
    bcf     INTCON,INTCON_INTF_POSITION
    bsf     INTCON,INTCON_PEIE_POSITION
    bsf     INTCON,INTCON_GIE_POSITION
    
    clrf    VAR
loop:
    ;  VAR = U U U U  D D D D 
    ;PORTC = 1 0 X X  D D D D
    movf    VAR,W
    movwf   DISPLAY_D
    bsf     DISPLAY_D,1; 7
    bcf     DISPLAY_D,0; 6
    movf    DISPLAY_D,W
    movwf   PORTC
    
    ;PORTC = 0 1 X X  U U U U
    movf    VAR,W
    movwf   DISPLAY_U
    swapf   DISPLAY_U,F
    bcf     DISPLAY_U,1; 7
    bsf     DISPLAY_U,0; 6
    movf    DISPLAY_U,W
    movwf   PORTC
    
    GOTO loop

; remaining code goes here

TABELA:
    addwf PCL,f 
    RETLW 0x0
    RETLW 0x0
    RETLW 0x1
    RETLW 0x1
    RETLW 0x2
    RETLW 0x2
    RETLW 0x2
    RETLW 0x3
    RETLW 0x3
    RETLW 0x4
    RETLW 0x4
    RETLW 0x4
    RETLW 0x5
    RETLW 0x5
    RETLW 0x5
    RETLW 0x6
    RETLW 0x6
    RETLW 0x7
    RETLW 0x7
    RETLW 0x7
    RETLW 0x8
    RETLW 0x8
    RETLW 0x9
    RETLW 0x9
    RETLW 0x9
    RETLW 0x10
    RETLW 0x10
    RETLW 0x11
    RETLW 0x11
    RETLW 0x11
    RETLW 0x12
    RETLW 0x12
    RETLW 0x13
    RETLW 0x13
    RETLW 0x13
    RETLW 0x14
    RETLW 0x14
    RETLW 0x14
    RETLW 0x15
    RETLW 0x15
    RETLW 0x16
    RETLW 0x16
    RETLW 0x16
    RETLW 0x17
    RETLW 0x17
    RETLW 0x18
    RETLW 0x18
    RETLW 0x18
    RETLW 0x19
    RETLW 0x19
    RETLW 0x20
    RETLW 0x20
    RETLW 0x20
    RETLW 0x21
    RETLW 0x21
    RETLW 0x21
    RETLW 0x22
    RETLW 0x22
    RETLW 0x23
    RETLW 0x23
    RETLW 0x23
    RETLW 0x24
    RETLW 0x24
    RETLW 0x25
    RETLW 0x25
    RETLW 0x25
    RETLW 0x26
    RETLW 0x26
    RETLW 0x27
    RETLW 0x27
    RETLW 0x27
    RETLW 0x28
    RETLW 0x28
    RETLW 0x29
    RETLW 0x29
    RETLW 0x29
    RETLW 0x30
    RETLW 0x30
    RETLW 0x30
    RETLW 0x31
    RETLW 0x31
    RETLW 0x32
    RETLW 0x32
    RETLW 0x32
    RETLW 0x33
    RETLW 0x33
    RETLW 0x34
    RETLW 0x34
    RETLW 0x34
    RETLW 0x35
    RETLW 0x35
    RETLW 0x36
    RETLW 0x36
    RETLW 0x36
    RETLW 0x37
    RETLW 0x37
    RETLW 0x38
    RETLW 0x38
    RETLW 0x38
    RETLW 0x39
    RETLW 0x39
    RETLW 0x39
    RETLW 0x40
    RETLW 0x40
    RETLW 0x41
    RETLW 0x41
    RETLW 0x41
    RETLW 0x42
    RETLW 0x42
    RETLW 0x43
    RETLW 0x43
    RETLW 0x43
    RETLW 0x44
    RETLW 0x44
    RETLW 0x45
    RETLW 0x45
    RETLW 0x45
    RETLW 0x46
    RETLW 0x46
    RETLW 0x46
    RETLW 0x47
    RETLW 0x47
    RETLW 0x48
    RETLW 0x48
    RETLW 0x48
    RETLW 0x49
    RETLW 0x49
    RETLW 0x50


; example of preloading EEPROM locations
    psect   edata,global,class=EEDATA,space=3,delta=2,noexec
    DB  5,4,3,2,1

    END     resetVec            ; directive 'end of program'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文