A
asic1984
Guest
hoi
Ik wil een code die lezen ADC en stuurt de waarden die via de rs232
Ik heb geprobeerd om de volgende code en simuleren in proteus maar niets werkt
voor Evert kanaal i am sturen eerst een karakter, die het kanaal dan de lagere en daarna de hoge waarden van de ADC
wenst dat een kan me helpen om het probleem
Code
rocessor 16f877
# include "p16f877.inc"org 0x00
goto start
org 0x04org 0x06start
BSF STATUS, RP0; BANK 1
MOVLW 0x00
MOVWF TRISB; HAVENS BC OUTPUT (OUTPUT DE DIGITALE waarde)
MOVWF TRISC; Configureer analoge pinnen / spanning referentie en digitale I / O (ADCON1)MOVLW B'10000000 '; vref IS EN VDD VSS EN ALLE pinnen ANALOG
MOVWF ADCON1; RECHT GERECHTVAARDIGDoproep Irs232;------------------------------------------------- ------------
lus
;------------------------------------------------- ------------Selecteer A / D ingangskanaal (ADCON0)
Selecteer A / D conversie klok (ADCON0)
; Schakel A / O-module (ADCON0)
BCF STATUS, RP0; BANK 0
MOVLW B'10000001 '
MOVWF ADCON0; Start conversie: Stel GO / DONE bit (ADCON0)
BSF ADCON0, 2
CALL DELAY; Polling voor de GO / GEDAAN beetje te worden gewist (met interrupts ingeschakeld);
WAIT1 BTFSC ADCON0, 2
GOTO WAIT1
; LEES DE WAARDE VAN OMZETTINGBCF STATUS, 5
MOVLW 84; VERZENDEN T
MOVWF TXREG
LOOP1 BTFSS PIR1, 4
GOTO LOOP1
BSF STATUS, 5
MOVFW ADRESL
BCF STATUS, 5
MOVWF TXREG
LOOP2 BTFSS PIR1, 4
GOTO LOOP2
MOVFW ADRESH
MOVWF TXREG
LOOP3 BTFSS PIR1, 4
GOTO LOOP3
;------------------------------------------------- -------------Selecteer A / D ingangskanaal (ADCON0)
Selecteer A / D conversie klok (ADCON0)
; Schakel A / O-module (ADCON0)
; BCF STATUS, RP0; BANK 0
MOVLW B'10001001 '
MOVWF ADCON0; Start conversie: Stel GO / DONE bit (ADCON0)
BSF ADCON0, 2; Polling voor de GO / GEDAAN beetje te worden gewist (met interrupts ingeschakeld);
WAIT2 BTFSC ADCON0, 2
GOTO WAIT2
; LEES DE WAARDE VAN OMZETTINGBCF STATUS, 5
MOVLW 69; E
MOVWF TXREG
LOOP4 BTFSS PIR1, 4
GOTO LOOP4
BSF STATUS, 5
MOVFW ADRESL
BCF STATUS, 5
MOVWF TXREG
LOOP5 BTFSS PIR1, 4
GOTO LOOP5
MOVFW ADRESH
MOVWF TXREG
LOOP6 BTFSS PIR1, 4
GOTO LOOP6
;------------------------------------------------- -------------Selecteer A / D ingangskanaal (ADCON0)
Selecteer A / D conversie klok (ADCON0)
; Schakel A / O-module (ADCON0)
; BCF STATUS, RP0; BANK 0
MOVLW B'10010001 '
MOVWF ADCON0; Start conversie: Stel GO / DONE bit (ADCON0)
BSF ADCON0, 2; Polling voor de GO / GEDAAN beetje te worden gewist (met interrupts ingeschakeld);
WAIT3 BTFSC ADCON0, 2
GOTO WAIT3
; LEES DE WAARDE VAN OMZETTINGBCF STATUS, 5
MOVLW 65; SEND A
MOVWF TXREG
LOOP7 BTFSS PIR1, 4
GOTO LOOP7
BSF STATUS, 5
MOVFW ADRESL
BCF STATUS, 5
MOVWF TXREG
LOOP8 BTFSS PIR1, 4
GOTO LOOP8
MOVFW ADRESH
MOVWF TXREG
LOOP9 BTFSS PIR1, 4
GOTO LOOP9;------------------------------------------------- -------Selecteer A / D ingangskanaal (ADCON0)
Selecteer A / D conversie klok (ADCON0)
; Schakel A / O-module (ADCON0)
; BCF STATUS, RP0; BANK 0
MOVLW B'10011001 '
MOVWF ADCON0; Start conversie: Stel GO / DONE bit (ADCON0)
BSF ADCON0, 2; Polling voor de GO / GEDAAN beetje te worden gewist (met interrupts ingeschakeld);
WAIT4 BTFSC ADCON0, 2
GOTO WAIT4
; LEES DE WAARDE VAN OMZETTINGBCF STATUS, 5
MOVLW 82; VERZENDEN R
MOVWF TXREG
LOOP10 BTFSS PIR1, 4
GOTO LOOP10
BSF STATUS, 5
MOVFW ADRESL
BCF STATUS, 5
MOVWF TXREG
LOOP11 BTFSS PIR1, 4
GOTO LOOP11
MOVFW ADRESH
MOVWF TXREG
LOOP12 BTFSS PIR1, 4
GOTO LOOP12
;------------------------------------------------- -------; Goto lus
;------------------------------------------------- ------------
Irs232
; Initialize de SPBRG registreren voor de juiste
; Baudrate.
Als een hoge snelheid baudrate gewenst is,
; Set bit BRGH
BSF STATUS, 5; BANK 1
MOVLW 42
MOVWF SPBRG; BAUD RATE 28,8 K
BSF TXSTA, 2; VOOR HOGE BAUD RATE
; Schakel de asynchrone seriële poort bij clearing
; bits SYNC en instelling beetje SPEN.BCF TXSTA, 4
BCF STATUS, 5; BANK 0
BSF RCSTA, 7; ENABLE Serial Port; Schakel de verzending door bits TXEN,
, die zal ook iets TXIF.BSF STATUS, 5
BSF TXSTA, 5terug;------------------------------------------------- -----------EINDE
Ik wil een code die lezen ADC en stuurt de waarden die via de rs232
Ik heb geprobeerd om de volgende code en simuleren in proteus maar niets werkt
voor Evert kanaal i am sturen eerst een karakter, die het kanaal dan de lagere en daarna de hoge waarden van de ADC
wenst dat een kan me helpen om het probleem
Code
# include "p16f877.inc"org 0x00
goto start
org 0x04org 0x06start
BSF STATUS, RP0; BANK 1
MOVLW 0x00
MOVWF TRISB; HAVENS BC OUTPUT (OUTPUT DE DIGITALE waarde)
MOVWF TRISC; Configureer analoge pinnen / spanning referentie en digitale I / O (ADCON1)MOVLW B'10000000 '; vref IS EN VDD VSS EN ALLE pinnen ANALOG
MOVWF ADCON1; RECHT GERECHTVAARDIGDoproep Irs232;------------------------------------------------- ------------
lus
;------------------------------------------------- ------------Selecteer A / D ingangskanaal (ADCON0)
Selecteer A / D conversie klok (ADCON0)
; Schakel A / O-module (ADCON0)
BCF STATUS, RP0; BANK 0
MOVLW B'10000001 '
MOVWF ADCON0; Start conversie: Stel GO / DONE bit (ADCON0)
BSF ADCON0, 2
CALL DELAY; Polling voor de GO / GEDAAN beetje te worden gewist (met interrupts ingeschakeld);
WAIT1 BTFSC ADCON0, 2
GOTO WAIT1
; LEES DE WAARDE VAN OMZETTINGBCF STATUS, 5
MOVLW 84; VERZENDEN T
MOVWF TXREG
LOOP1 BTFSS PIR1, 4
GOTO LOOP1
BSF STATUS, 5
MOVFW ADRESL
BCF STATUS, 5
MOVWF TXREG
LOOP2 BTFSS PIR1, 4
GOTO LOOP2
MOVFW ADRESH
MOVWF TXREG
LOOP3 BTFSS PIR1, 4
GOTO LOOP3
;------------------------------------------------- -------------Selecteer A / D ingangskanaal (ADCON0)
Selecteer A / D conversie klok (ADCON0)
; Schakel A / O-module (ADCON0)
; BCF STATUS, RP0; BANK 0
MOVLW B'10001001 '
MOVWF ADCON0; Start conversie: Stel GO / DONE bit (ADCON0)
BSF ADCON0, 2; Polling voor de GO / GEDAAN beetje te worden gewist (met interrupts ingeschakeld);
WAIT2 BTFSC ADCON0, 2
GOTO WAIT2
; LEES DE WAARDE VAN OMZETTINGBCF STATUS, 5
MOVLW 69; E
MOVWF TXREG
LOOP4 BTFSS PIR1, 4
GOTO LOOP4
BSF STATUS, 5
MOVFW ADRESL
BCF STATUS, 5
MOVWF TXREG
LOOP5 BTFSS PIR1, 4
GOTO LOOP5
MOVFW ADRESH
MOVWF TXREG
LOOP6 BTFSS PIR1, 4
GOTO LOOP6
;------------------------------------------------- -------------Selecteer A / D ingangskanaal (ADCON0)
Selecteer A / D conversie klok (ADCON0)
; Schakel A / O-module (ADCON0)
; BCF STATUS, RP0; BANK 0
MOVLW B'10010001 '
MOVWF ADCON0; Start conversie: Stel GO / DONE bit (ADCON0)
BSF ADCON0, 2; Polling voor de GO / GEDAAN beetje te worden gewist (met interrupts ingeschakeld);
WAIT3 BTFSC ADCON0, 2
GOTO WAIT3
; LEES DE WAARDE VAN OMZETTINGBCF STATUS, 5
MOVLW 65; SEND A
MOVWF TXREG
LOOP7 BTFSS PIR1, 4
GOTO LOOP7
BSF STATUS, 5
MOVFW ADRESL
BCF STATUS, 5
MOVWF TXREG
LOOP8 BTFSS PIR1, 4
GOTO LOOP8
MOVFW ADRESH
MOVWF TXREG
LOOP9 BTFSS PIR1, 4
GOTO LOOP9;------------------------------------------------- -------Selecteer A / D ingangskanaal (ADCON0)
Selecteer A / D conversie klok (ADCON0)
; Schakel A / O-module (ADCON0)
; BCF STATUS, RP0; BANK 0
MOVLW B'10011001 '
MOVWF ADCON0; Start conversie: Stel GO / DONE bit (ADCON0)
BSF ADCON0, 2; Polling voor de GO / GEDAAN beetje te worden gewist (met interrupts ingeschakeld);
WAIT4 BTFSC ADCON0, 2
GOTO WAIT4
; LEES DE WAARDE VAN OMZETTINGBCF STATUS, 5
MOVLW 82; VERZENDEN R
MOVWF TXREG
LOOP10 BTFSS PIR1, 4
GOTO LOOP10
BSF STATUS, 5
MOVFW ADRESL
BCF STATUS, 5
MOVWF TXREG
LOOP11 BTFSS PIR1, 4
GOTO LOOP11
MOVFW ADRESH
MOVWF TXREG
LOOP12 BTFSS PIR1, 4
GOTO LOOP12
;------------------------------------------------- -------; Goto lus
;------------------------------------------------- ------------
Irs232
; Initialize de SPBRG registreren voor de juiste
; Baudrate.
Als een hoge snelheid baudrate gewenst is,
; Set bit BRGH
BSF STATUS, 5; BANK 1
MOVLW 42
MOVWF SPBRG; BAUD RATE 28,8 K
BSF TXSTA, 2; VOOR HOGE BAUD RATE
; Schakel de asynchrone seriële poort bij clearing
; bits SYNC en instelling beetje SPEN.BCF TXSTA, 4
BCF STATUS, 5; BANK 0
BSF RCSTA, 7; ENABLE Serial Port; Schakel de verzending door bits TXEN,
, die zal ook iets TXIF.BSF STATUS, 5
BSF TXSTA, 5terug;------------------------------------------------- -----------EINDE