刚学PIC,写了个GPIO的端口测试程序,GP0、GP1、GP2、GP4、GP5循环亮灯,测试发现GP4、GP5输出高低电平正常,而GP0、GP1、GP2却一直为低电平(单片机仅MCLR引脚接了上拉10K、下拉0.1uF电容,其它端口未接任何外部电路),OPTION、CONFIG以及TRIS都有设置,纠结好久了,请各位PIC高手帮忙看下,问题在哪?
__config 0x0ffa ; MCLR使能,代码保护关,WDT关,选择内部RC时钟
INDF equ 00h
TMR0 equ 01h
PCL equ 02h
STATUS equ 03h
PSR equ 04h
OSCCAL equ 05h
GPIO equ 06h
org 000h
movlw OSCCAL
main
clrf GPIO
movlw 00h
tris GPIO
movlw 00h
option
loop
clrf GPIO
movlw 01h
movwf GPIO ;点亮GP0
call delay
call delay
movlw 02h
movwf GPIO ;点亮GP1
call delay
call delay
movlw 04h
movwf GPIO ;点亮GP2
call delay
call delay
movlw 10h
movwf GPIO ;点亮GP4
call delay
call delay
movlw 20h
movwf GPIO ;点亮GP5
call delay
call delay
goto loop
delay
movlw 0ffh
movwf 11h
movlw 0ffh
movwf 12h
decfsz 12h, 1
goto $-1
decfsz 11h, 1
goto $-4
retlw 0
end
|