查看: 1421|回复: 2
|
PIC16F877A的ADC问题
[复制链接]
|
|
各人参考书后,写了个program,convert去hex file没有error,但test了没法走
code:
;8BITSADC.TXT. This sets PORTA as an INPUT with A0
; and A1 as analogue inputs and A2 and A3
; as digital PORTB is an OUTPUT.
;******************************************************************
;EQUATES SECTION
TMR0 EQU 1 ;means TMR0 is file 1.
STATUS EQU 3 ;means STATUS is file 3.
PORTA EQU 5 ;means PORTA is file 5.
PORTB EQU 6 ;means PORTB is file 6.
ZEROBIT EQU 2 ;means ZEROBIT is bit 2.
ADCON0 EQU 8 ;A/D Configuration reg.0
ADCON1 EQU 8 ;A/D Configuration reg.1
ADRES EQU 9 ;A/D Result register.
CARRY EQU 0 ;Carry bit in Status Register
COUNT EQU 0CH ;means COUNT is file 0C.
;a register to count events.
;******************************************************************
LIST P=16F877A ;we are using the 16F877A
ORG 0 ;the start address in memory is 0
GOTO START ;goto start!
;******************************************************************
;CONFIGURATION SECTION
START BSF STATUS,5 ;Turns to Bank1
MOVLW B'00011111' ;5bits of PORTA are I/P
TRIS PORTA
MOVLW B'00000010' ;A0,A1 are analogue
MOVWF ADCON1 ;A2,A3 are digital I/P
MOVLW B'00000000'
TRIS PORTB ; PORTB is OUTPUT
BCF STATUS,5 ;Return to Bank0
MOVLW B'00000001' ;Turns on A/D converter
MOVWF ADCON0 ;and selects channel AN0
CLRF PORTA ;Clears PORTA
CLRF PORTB ;Clears PORTB
;******************************************************************
BEGIN BSF ADCON0,2 ;Take Measurement
WAIT BTFSC ADCON0,2 ;Wait untill reading done
GOTO WAIT
MOVF ADRES,W ;Move A/D Result into W
MOVWF PORTB ;Move W into PORTB
GOTO BEGIN
END
有6个warning
Warning[205] D:\MY DOCUMENTS\FYP DOC\PIC SOFT CODE\8BITSADC.TXT 21 : Found directive in column 1. (LIST)
Warning[205] D:\MY DOCUMENTS\FYP DOC\PIC SOFT CODE\8BITSADC.TXT 22 : Found directive in column 1. (ORG)
Warning[203] D:\MY DOCUMENTS\FYP DOC\PIC SOFT CODE\8BITSADC.TXT 23 : Found opcode in column 1. (GOTO)
Warning[224] D:\MY DOCUMENTS\FYP DOC\PIC SOFT CODE\8BITSADC.TXT 30 : Use of this instruction is not recommended.
Warning[224] D:\MY DOCUMENTS\FYP DOC\PIC SOFT CODE\8BITSADC.TXT 34 : Use of this instruction is not recommended.
Warning[205] D:\MY DOCUMENTS\FYP DOC\PIC SOFT CODE\8BITSADC.TXT 50 : Found directive in column 1. (END)
高手可以帮我看下有什么问题吗?谢谢
[ 本帖最后由 retnuoc 于 11-7-2007 12:11 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 16-7-2007 11:12 AM
|
显示全部楼层
回复 #1 retnuoc 的帖子
可以告诉我比较清楚些吗?你的AD input 是什么?会不会是input那边有问题? |
|
|
|
|
|
|
|
发表于 18-7-2007 09:14 AM
|
显示全部楼层
原帖由 retnuoc 于 11-7-2007 12:06 PM 发表
各人参考书后,写了个program,convert去hex file没有error,但test了没法走
没时间看你的ASM code,但如可以用C来写, 几行就搞定了。
参考旧帖, 有ADC的源码。 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|