babboy12345
New Member
i had been build all my program....no any error,and i burn into my MCU and try it,but i still cannot get the output from portB,any1 can tell me why??
say it cleary,i'm not familiar with writing,but i try many time to solve my program problems,but problems still occur,so i really need a help from you all. hundred thanks for those reply this thread!
Code:
LIST P=16F877A
INCLUDE "P16F877a.inc"
__CONFIG _CP_OFF & _WDT_OFF & _HS_OSC & _PWRTE_ON
CHK1 EQU 0X21
CNT1 EQU 0x22
CNT2 EQU 0x23
count EQU 0x20
org 0x000
nop
BSF STATUS,RP0
MOVLW H'FF'
MOVWF TRISA
movlw H'00';
movwf TRISB;
banksel PORTA
BCF STATUS,RP0
clrf PORTB
banksel ADCON1
movlw b'10000000'
movwf ADCON1
banksel ADCON0
movlw b'10000001'
movwf ADCON0
getAD movlw 007
movwf count
down decfsz count
goto down
bsf ADCON0,GO
wait btfsc ADCON0,GO
goto wait
return
delay MOVLW D'5'
MOVWF CNT2
CON1 MOVLW H'FF'
MOVWF CNT1
DECFSZ CNT1,1
GOTO $-1
DECFSZ CNT2,1
GOTO CON1
RETURN
start call getAD ; get adc result store at adresh
movlw 0xC8 ;
subwf ADRESH,1 ; adc result in adresh will minus....
btfsc ADRESH,0 ;...C8 and the answer store at adresh again..
goto start ; if answer in adresh is not 0....then the program will jump to start again...
btfsc ADRESH,1
goto start
btfsc ADRESH,2
goto start
btfsc ADRESH,3
goto start
btfsc ADRESH,4
goto start
btfsc ADRESH,5
goto start
btfsc ADRESH,6
goto start
btfsc ADRESH,7
goto start
bsf PORTB,1
call delay
END
say it cleary,i'm not familiar with writing,but i try many time to solve my program problems,but problems still occur,so i really need a help from you all. hundred thanks for those reply this thread!