Hello all
I'm probably overlooking the obvious but I can't seem to get the USART on the 18F252 working. I've tested Port RC6 to see if anything is being transmitted but the output remains high. I suspect that I haven't configured the associated registers properly or the Test Routine is wrong. Using other code I know the port works OK. Below are a few details, can anyone advise please?
Thanks, Simon
PIC18F252 Xtal=7.3728 Mhz Desired BAUD rate: 38400 Interrupts not used
; Configure Port C ; CLRF LATC MOVLW B'10010000' ;RC4:RC7=inputs. MOVWF TRISC ;RC0-RC3, RC5-RC6=outputs. ; ; Configure USART ; MOVLW D'2' ;Set BAUD rate. MOVWF SPBRG
;Configure Transmit Status ;and Control. ; MOVLW B'00100000' ;b7: CSRC = don't care here. MOVWF TXSTA ;b6: TX9 = 0 (8-bit mode). ;b5: TXEN = 1, Transmit enabled. ;b4: SYNC = Asynchronous mode. ;b3: unimplemented. ;b2: BRGH = 0, Low Speed mode. ;b1: TRMT = don't care here. ;b0: TX9D = 9th bit for parity. ; ;Configure Receive Status ;and Control. ; MOVLW B'10000000' ;b7: SPEN = 1, Serial port enabled. MOVWF RCSTA ;b6: RX9 = 0, 8-bit reception. ;b5: SREN = 0, don't care for async. ;b4: CREN = 0, Rx disabled. ;b3: ADDEN = 0, 9th bit for parity. ;b2: FERR = 0, don't care here. ;b1: OERR = 0, don't care here. ;b0: RX9D = 0, don't care here.
;Test Routine
LOOP MOVLW A'S' MOVWF TXREG BTFSS PIR1,TXIF GOTO $-2 GOTO LOOP
I've setup a breakpoint at LOOP