mình vừa bắt đầu tìm hiểu pic nên có chút khó khăn mong các b chỉ bảo .
mình copy đoạn code điều khiển led từ giáo trình vào phần mềm mplap làm đúng các bước theo hướng dẫn trong sách khi dịch thì báo lỗi không biết thiếu cái gì . mình nghĩ code thì viết đúng nhưng mấy cái dòng đầu thì không biết thế đã đủ chưa , #include hay include thôi là đúng . Còn nữa là đoạn lệnh _config........ là gì . mình copy cả code và phần khi dịch báo lỗi cho các b chỉ nhé .
CODE:
processor 16f877a ; khai baùo vi ñieàu khieån
include <p16f877a.inc> ; header file ñính keøm
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC &
_WRT_OFF & _LVP_OFF & _CPD_OFF
; khai baùo caùc “Configuration bits”
;--------------------------------------------------------------------------------------------------------------
;Khai baùo bieán
;--------------------------------------------------------------------------------------------------------------
count1 EQU 0x20 ; duøng cho chöông trình delay
counta EQU 0x21 ; duøng cho chöông trình delay
countb EQU 0x22 ; duøng cho chöông trình delay
ORG 0x000 ; ñòa chæ baét ñaàu chöông trình
GOTO start
start ; chöông trình chính baét ñaàu taïi ñaây
BCF STATUS,RP1
BCF STATUS,RP0 ; choïn BANK0
CLRF PORTB ; xoùa PORTB
BSF STATUS,RP0 ; choïn BANK1
MOVLW 0x00
MOVWF TRISB ; PORTB <- outputs
BCF STATUS,RP0 ; choïn BANK0
MOVLW 0x8F ; giaù trò baát kì caàn ñöa ra PORTB
MOVWF PORTB ; PORTB <- 8Fh
loop CALL delay100ms ; goïi chöông trình con delay100ms
RRF PORTB,1 ; dòch phaûi PORTB
GOTO loop ; voøng laëp voâ haïn
delay100ms
MOVLW d’100’
MOVWF count1
d1 MOVLW 0xC7
MOVWF counta
MOVLW 0x01
MOVWF countb
delay_0
DECFSZ counta,1
GOTO $+2
DECFSZ countb,1
GOTO delay_0
DECFSZ count1,1
GOTO d1 ; delay 100ms
RETLW 0x00 ; trôû veà chöông trình chính
END ; keát thuùc chöông trình
KHI DỊCH THÌ NÓ BÁO LỖI THẾ NÀY :
----------------------------------------------------------------------
Debug build of project `C:\Documents and Settings\Administrator.DHHH-314BA344EC\My Documents\bhjb.mcp' started.
Language tool versions: MPASMWIN.exe v5.37, mplink.exe v4.37, mplib.exe v4.37
Preprocessor symbol `__DEBUG' is defined.
Thu Jan 24 18:35:11 2013
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\Documents and Settings\Administrator.DHHH-314BA344EC\My Documents\bhjb.mcs".
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F877A "bbbbbb.asm" /l"bbbbbb.lst" /e"bbbbbb.err" /d__DEBUG=1
Warning[205] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 3 : Found directive in column 1. (processor)
Warning[205] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 4 : Found directive in column 1. (include)
Warning[205] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 5 : Found directive in column 1. (__CONFIG)
Error[128] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 5 : Missing argument(s)
Error[108] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 6 : Illegal character (&)
Warning[205] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 14 : Found directive in column 1. (ORG)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 15 : Found opcode in column 1. (GOTO)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 17 : Found opcode in column 1. (BCF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 18 : Found opcode in column 1. (BCF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 19 : Found opcode in column 1. (CLRF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 20 : Found opcode in column 1. (BSF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 21 : Found opcode in column 1. (MOVLW)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 22 : Found opcode in column 1. (MOVWF)
Message[302] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 22 : Register in operand not in bank 0. Ensure that bank bits are correct.
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 23 : Found opcode in column 1. (BCF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 24 : Found opcode in column 1. (MOVLW)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 25 : Found opcode in column 1. (MOVWF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 27 : Found opcode in column 1. (RRF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 28 : Found opcode in column 1. (GOTO)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 30 : Found opcode in column 1. (MOVLW)
Error[113] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 30 : Symbol not previously defined (d’100’)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 31 : Found opcode in column 1. (MOVWF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 33 : Found opcode in column 1. (MOVWF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 34 : Found opcode in column 1. (MOVLW)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 35 : Found opcode in column 1. (MOVWF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 37 : Found opcode in column 1. (DECFSZ)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 38 : Found opcode in column 1. (GOTO)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 39 : Found opcode in column 1. (DECFSZ)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 40 : Found opcode in column 1. (GOTO)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 41 : Found opcode in column 1. (DECFSZ)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 42 : Found opcode in column 1. (GOTO)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 43 : Found opcode in column 1. (RETLW)
Warning[205] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 44 : Found directive in column 1. (END)
Halting build on first failure as requested.
----------------------------------------------------------------------
Debug build of project `C:\Documents and Settings\Administrator.DHHH-314BA344EC\My Documents\bhjb.mcp' failed.
Language tool versions: MPASMWIN.exe v5.37, mplink.exe v4.37, mplib.exe v4.37
Preprocessor symbol `__DEBUG' is defined.
Thu Jan 24 18:35:24 2013
----------------------------------------------------------------------
BUILD FAILE
MÌNH ĐÃ XEM QUA CẤU TRÚC CHƯƠNG TRÌNH ASM RỒI THÌ THẤY KHÔNG CÓ GÌ SAI NGOẠI TRỪ TRƯỚC
INCLUDE PHẢI THÊM # . MÌNH ĐÃ SỬA LẠI NHƯNG KHI DỊCH VẪN BÁO LỖI . VẬY MONG CÁC B CHỈ GIÚP . THANKSSSS
mình copy đoạn code điều khiển led từ giáo trình vào phần mềm mplap làm đúng các bước theo hướng dẫn trong sách khi dịch thì báo lỗi không biết thiếu cái gì . mình nghĩ code thì viết đúng nhưng mấy cái dòng đầu thì không biết thế đã đủ chưa , #include hay include thôi là đúng . Còn nữa là đoạn lệnh _config........ là gì . mình copy cả code và phần khi dịch báo lỗi cho các b chỉ nhé .
CODE:
processor 16f877a ; khai baùo vi ñieàu khieån
include <p16f877a.inc> ; header file ñính keøm
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC &
_WRT_OFF & _LVP_OFF & _CPD_OFF
; khai baùo caùc “Configuration bits”
;--------------------------------------------------------------------------------------------------------------
;Khai baùo bieán
;--------------------------------------------------------------------------------------------------------------
count1 EQU 0x20 ; duøng cho chöông trình delay
counta EQU 0x21 ; duøng cho chöông trình delay
countb EQU 0x22 ; duøng cho chöông trình delay
ORG 0x000 ; ñòa chæ baét ñaàu chöông trình
GOTO start
start ; chöông trình chính baét ñaàu taïi ñaây
BCF STATUS,RP1
BCF STATUS,RP0 ; choïn BANK0
CLRF PORTB ; xoùa PORTB
BSF STATUS,RP0 ; choïn BANK1
MOVLW 0x00
MOVWF TRISB ; PORTB <- outputs
BCF STATUS,RP0 ; choïn BANK0
MOVLW 0x8F ; giaù trò baát kì caàn ñöa ra PORTB
MOVWF PORTB ; PORTB <- 8Fh
loop CALL delay100ms ; goïi chöông trình con delay100ms
RRF PORTB,1 ; dòch phaûi PORTB
GOTO loop ; voøng laëp voâ haïn
delay100ms
MOVLW d’100’
MOVWF count1
d1 MOVLW 0xC7
MOVWF counta
MOVLW 0x01
MOVWF countb
delay_0
DECFSZ counta,1
GOTO $+2
DECFSZ countb,1
GOTO delay_0
DECFSZ count1,1
GOTO d1 ; delay 100ms
RETLW 0x00 ; trôû veà chöông trình chính
END ; keát thuùc chöông trình
KHI DỊCH THÌ NÓ BÁO LỖI THẾ NÀY :
----------------------------------------------------------------------
Debug build of project `C:\Documents and Settings\Administrator.DHHH-314BA344EC\My Documents\bhjb.mcp' started.
Language tool versions: MPASMWIN.exe v5.37, mplink.exe v4.37, mplib.exe v4.37
Preprocessor symbol `__DEBUG' is defined.
Thu Jan 24 18:35:11 2013
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\Documents and Settings\Administrator.DHHH-314BA344EC\My Documents\bhjb.mcs".
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F877A "bbbbbb.asm" /l"bbbbbb.lst" /e"bbbbbb.err" /d__DEBUG=1
Warning[205] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 3 : Found directive in column 1. (processor)
Warning[205] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 4 : Found directive in column 1. (include)
Warning[205] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 5 : Found directive in column 1. (__CONFIG)
Error[128] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 5 : Missing argument(s)
Error[108] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 6 : Illegal character (&)
Warning[205] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 14 : Found directive in column 1. (ORG)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 15 : Found opcode in column 1. (GOTO)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 17 : Found opcode in column 1. (BCF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 18 : Found opcode in column 1. (BCF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 19 : Found opcode in column 1. (CLRF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 20 : Found opcode in column 1. (BSF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 21 : Found opcode in column 1. (MOVLW)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 22 : Found opcode in column 1. (MOVWF)
Message[302] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 22 : Register in operand not in bank 0. Ensure that bank bits are correct.
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 23 : Found opcode in column 1. (BCF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 24 : Found opcode in column 1. (MOVLW)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 25 : Found opcode in column 1. (MOVWF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 27 : Found opcode in column 1. (RRF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 28 : Found opcode in column 1. (GOTO)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 30 : Found opcode in column 1. (MOVLW)
Error[113] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 30 : Symbol not previously defined (d’100’)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 31 : Found opcode in column 1. (MOVWF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 33 : Found opcode in column 1. (MOVWF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 34 : Found opcode in column 1. (MOVLW)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 35 : Found opcode in column 1. (MOVWF)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 37 : Found opcode in column 1. (DECFSZ)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 38 : Found opcode in column 1. (GOTO)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 39 : Found opcode in column 1. (DECFSZ)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 40 : Found opcode in column 1. (GOTO)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 41 : Found opcode in column 1. (DECFSZ)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 42 : Found opcode in column 1. (GOTO)
Warning[203] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 43 : Found opcode in column 1. (RETLW)
Warning[205] C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.DHHH-314BA344EC\MY DOCUMENTS\BBBBBB.ASM 44 : Found directive in column 1. (END)
Halting build on first failure as requested.
----------------------------------------------------------------------
Debug build of project `C:\Documents and Settings\Administrator.DHHH-314BA344EC\My Documents\bhjb.mcp' failed.
Language tool versions: MPASMWIN.exe v5.37, mplink.exe v4.37, mplib.exe v4.37
Preprocessor symbol `__DEBUG' is defined.
Thu Jan 24 18:35:24 2013
----------------------------------------------------------------------
BUILD FAILE
MÌNH ĐÃ XEM QUA CẤU TRÚC CHƯƠNG TRÌNH ASM RỒI THÌ THẤY KHÔNG CÓ GÌ SAI NGOẠI TRỪ TRƯỚC
INCLUDE PHẢI THÊM # . MÌNH ĐÃ SỬA LẠI NHƯNG KHI DỊCH VẪN BÁO LỖI . VẬY MONG CÁC B CHỈ GIÚP . THANKSSSS
Comment