Ich habe externe Widerstände, ich betreibe das Ganez auf dem Vellemen K8048.
Das mit den 20 MHZ habe ich nicht verstanden.
Der Code sieht nun folgendermassen aus.
Warum geht denn LED1, pin 0 on PortB, nicht auf high, wenn ich Daten via RS232 sende?
Code:
;
; Handler for RS232 communication
; ------------------------------
;
;
;-------------------------------------------------------------------------------------------------
list p=16f627
#include "p16f627.inc"
CHAR equ 0X22
__CONFIG _BODEN_ON & _CP_OFF & _DATA_CP_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _MCLRE_ON & _XT_OSC
ERRORLEVEL -302
org 0x00
goto MAIN
org 0x04
org 0x05
;*************************************************************
MAIN
;*************************************************************
;-----------------------------------------------------------------------------
INITUSART
;-----------------------------------------------------------------------------
BSF STATUS,RP0 ; switch to Bank1
MOVLW 0x20 ; sender: RS232
MOVWF TXSTA ;
BCF STATUS,RP0 ; switch to Bank 0
MOVLW 0x90 ; receiver: RS232
MOVWF RCSTA ;
movlw 0x07 ; Comparator aus und auf
movwf CMCON ; Digital IO
bsf STATUS, RP0 ; switch to bank1
movlw b'00000010' ; RB1 = IN, sonst alles OUT
movwf TRISA ; /
bcf STATUS, RP0 ; switch to bank0
;-----------------------------------------------------------------------------
SETBAUD
;-----------------------------------------------------------------------------
BSF STATUS,RP0 ; Bank1
MOVLW 15 ; Set Baud rate 19,2 kBPS bei 20 MHz
MOVWF SPBRG
BCF TXSTA, BRGH ; BRGH=0
BCF STATUS,RP0 ; Bank 0
;-----------------------------------------------------------------------------
CLRPORTS
;-----------------------------------------------------------------------------
clrf PORTA
clrf PORTB
;-----------------------------------------------------------------------------
RECDATA1
;-----------------------------------------------------------------------------
btfss PIR1,RCIF ; sind Daten da ?
goto RECDATA1 ; nein, noch keine Daten da
;movfw RCREG ; RS232-Register auslesen
;movwf CHAR ; und in den Speicher nach 'Zeichen' schreiben
;-----------------------------------------------------------------------------
SETB0ON ; set pin 0 on PortB to high
;-----------------------------------------------------------------------------
; bsf STATUS, RP0 ; switch to bank1
; bcf TRISB ^ 0x80, 0 ; set on port B pin 0 as output
; bcf STATUS, RP0 ; switch back to bank0
bsf PORTB,0 ; set bit 0 on PortB to high
;-----------------------------------------------------------------------------
LOOP ; long loop, this allows to see an LED
;-----------------------------------------------------------------------------
count1 equ 15h
count2 equ 16h
L1 decfsz count1,1
goto L1
decfsz count2,1
goto L1
goto LOOP ; just for testing
end
Lesezeichen