15.02.2013 Aufrufe

Das Magazin für Funk Elektronik · Computer - FTP Directory Listing

Das Magazin für Funk Elektronik · Computer - FTP Directory Listing

Das Magazin für Funk Elektronik · Computer - FTP Directory Listing

MEHR ANZEIGEN
WENIGER ANZEIGEN
  • Keine Tags gefunden...

Erfolgreiche ePaper selbst erstellen

Machen Sie aus Ihren PDF Publikationen ein blätterbares Flipbook mit unserer einzigartigen Google optimierten e-Paper Software.

;******************************************************<br />

;Autor : 1995<br />

; : Klaus Sander/Fred Ziebell<br />

;Version : ‘9.95<br />

;Projekt : #602 / par2ser<br />

;Layout : #602 / Test SANDER ELEC-<br />

TRONIC<br />

;PIC: : 16C54<br />

;<strong>Funk</strong>tion : ser –> par , par –> ser<br />

; :<br />

;******************************************************<br />

;Programmfunktionen:<br />

;<br />

;<br />

;******************************************************<br />

; Voreinstellungen, Reset, Kopfdaten<br />

und Routinen<br />

;<br />

title „PAR2SER K.SANDER F.ZIEBELL“<br />

;projekt titel<br />

list f=INHX8M<br />

; Objektcode Format des Assemblers<br />

list n=60<br />

; Zeilenanzahl <strong>für</strong> <strong>Listing</strong><br />

;<br />

;<br />

; Bestimmung des Reset-Vektors<br />

;<br />

;<br />

RESET_ADR equ 1FFH<br />

;<br />

;<br />

;<br />

RESET ORG RESET_ADR<br />

goto START<br />

ORG 0000H<br />

;<br />

;******************************************************<br />

*<br />

;<br />

; Prozessorregister<br />

;<br />

;<br />

; Page PIC-Typ<br />

INDIREKTequ 00H ;0 16cXX<br />

RTCC equ 01H ;0 16cXX<br />

OPTIONREG equ 01H ;1<br />

16c71/84<br />

PC equ 02H ;0 16c5X<br />

PCL equ 02H ;0 16c71/84<br />

STATUS equ 03H ;0 16cXX<br />

FSR equ 04H ;0 16cXX<br />

PORTA equ 05H ;0 16cXX<br />

TRISA equ 05H ;1 16c71/84<br />

PORTB equ 06H ;0 16cXX<br />

TRISB equ 06H ;1 16c71/84<br />

PORTC equ 07H ;0 16c57<br />

ADCON0 equ 08H ;0 16c71<br />

ADCON1 equ 08H ;1 16c71<br />

EEDATA equ 08H ;0 16c84<br />

EECON1 equ 08H ;1 16c84<br />

ADRES equ 09H ;0 16c71<br />

EEADR equ 09H ;0 16c84<br />

EECON2 equ 09H ;1 16c84<br />

PCH equ 0AH ;0 16c71/84<br />

INCON equ 0BH ;0 16c71/84<br />

;<br />

; Variable<br />

;<br />

TEMP1 equ 0cH ;<br />

TEMP2 equ 0dH ;<br />

TEMP3 equ 0eH ;<br />

;<br />

TX_DELAY equ 8AH<br />

; Verzögerungszeit <strong>für</strong> 2400 Bit/s<br />

RX_DELAY equ 8AH ;<br />

RS_DELAY equ 00H<br />

RS_DATA equ 12H ; Sendebyte<br />

Praktische <strong>Elektronik</strong><br />

Programmlisting <strong>für</strong> die Verwendung des PIC 16C54 als universeller asynchroner serieller Sender und Empfänger<br />

RS_TIME equ 13H<br />

RS_COUNT equ 14H ; Schleifenzähler<br />

RS_PORT equ PORTA<br />

RS_BIT equ 0H<br />

;<br />

; Bit-Variablen<br />

;<br />

CARRY equ 0<br />

ZFLAG equ 2<br />

REGW equ 0<br />

REGF equ 1<br />

PAGE0 equ 5 ;Bit <strong>für</strong> Page<br />

;<br />

;<br />

;————————————————————<br />

RS_WAIT movlw RS_DELAY<br />

;Wartezeit <strong>für</strong> Bitlänge<br />

X_WAIT movwf RS_TIME<br />

RS_W1 decfsz RS_TIME,REGF<br />

goto RS_W1<br />

retlw 0<br />

;————————————————————<br />

TX_RS movlw .8<br />

;Zähler <strong>für</strong> 8 bit<br />

movwf RS_COUNT<br />

bcf RS_PORT,RS_BIT<br />

;sende Startbit<br />

call RS_WAIT<br />

TX_RSL1 btfsc RS_DATA,0<br />

goto TX_SETB<br />

goto TX_CLRB<br />

TX_SETB bsf RS_PORT,RS_BIT ;sende high<br />

call RS_WAIT<br />

goto TX_NXTB<br />

TX_CLRB bcf RS_PORT,RS_BIT ;sende low<br />

call RS_WAIT<br />

goto TX_NXTB<br />

TX_NXTB rrf RS_DATA,REGF<br />

decfsz RS_COUNT,REGF<br />

;sind alle bits weg?<br />

goto TX_RSL1<br />

bsf RS_PORT,RS_BIT<br />

;sende Stopbit<br />

call RS_WAIT<br />

retlw 0<br />

;zurück zur Hauptschleife<br />

;————————————————————<br />

RX_RS movlw .8 ;Zähler <strong>für</strong> 8 bit<br />

movwf RS_COUNT<br />

RX_RSL1 btfsc RS_PORT,RS_BIT<br />

;warte auf Startbit<br />

goto RX_RSL1<br />

movlw 45h<br />

;setze halbe Bitzeit<br />

call X_WAIT<br />

bsf PORTA,3<br />

;reset Byte bereit<br />

btfsc RS_PORT,RS_BIT<br />

goto RX_RSL1<br />

RX_TSTB call RS_WAIT<br />

btfsc RS_PORT,RS_BIT<br />

;teste Empfangsbit<br />

goto RX_SETB<br />

goto RX_CLRB<br />

RX_SETB bsf STATUS, CARRY ;setze high<br />

goto RX_NXTB<br />

RX_CLRB bcf STATUS, CARRY ;setze low<br />

goto RX_NXTB<br />

RX_NXTB rrf RS_DATA,REGF<br />

decfsz RS_COUNT,REGF<br />

;alle 8 bit angekommen?<br />

goto RX_TSTB<br />

retlw 0<br />

;zurück nach MAIN<br />

;———————————————————<br />

;<br />

; Programmstart<br />

;<br />

START clrwdt<br />

;Watchdog inaktiv<br />

clrw<br />

option<br />

;alles ohne Rtcc<br />

movwf PORTA<br />

;alle Portleitungen auf low<br />

movwf PORTB<br />

movlw 0FH<br />

;Port a wird Eingang a0-a3<br />

tris PORTA<br />

movlw 0FFH<br />

;Port b wird Eingang b0-b7<br />

tris PORTB<br />

movlw 82H<br />

;nach dem Einschalten<br />

movwf TEMP1<br />

;ca. 100ms warten<br />

START1 movlw 0FFH<br />

call X_WAIT<br />

decfsz TEMP1,REGF<br />

goto START1<br />

btfss PORTA,1<br />

;0 = par – > ser , 1 = ser – > par<br />

goto PARSER<br />

SERPAR movlw RX_DELAY<br />

;Konfiguration lesen<br />

movwf RS_DELAY<br />

;und einstellen<br />

movlw 01H<br />

movwf PORTA<br />

movlw 07H<br />

tris PORTA<br />

clrw<br />

;Port b ist Ausgang<br />

movwf PORTB<br />

tris PORTB<br />

SERPAR1 call RX_RS<br />

;hole serielles Byte<br />

movf RS_DATA,REGW<br />

movwf PORTB<br />

bcf PORTA,3<br />

;Byte steht bereit<br />

goto SERPAR1<br />

PARSER movlw TX_DELAY<br />

;Konfiguration lesen<br />

movwf RS_DELAY<br />

;und einstellen<br />

movlw 09H<br />

movwf PORTA<br />

movlw 06H<br />

tris PORTA<br />

movlw 0FFH<br />

;Port b ist Eingang<br />

movwf PORTB<br />

tris PORTB<br />

PARSER0 bsf PORTA,3<br />

;Datum kann angelegt werden<br />

PARSER1 btfsc PORTA,2<br />

;sind Daten an Port b gültig?<br />

goto PARSER1<br />

PARSER2 btfss PORTA,2<br />

;Puls wieder weg?<br />

goto PARSER2<br />

bcf PORTA,3<br />

;warte bis Byte übertragen<br />

movf PORTB,REGW<br />

movwf RS_DATA<br />

;Datum ins Senderegister<br />

call TX_RS<br />

;und senden<br />

goto PARSER0<br />

;———————————————————<br />

END<br />

FA 11/95 • 1189

Hurra! Ihre Datei wurde hochgeladen und ist bereit für die Veröffentlichung.

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!