The default baud rate of SKKCA-21 is 115200bps. I am using Hyperterminal to test.
Hardware: PIC16F877A, 20MHz Resonator.
Programming Language: PICBasicPro
The question is "
What is the coding i should set if i want to set it to 9600bps"?
The coding below doesn't work if SPBRG is set to 129 (9600bps).
Nothing is displayed when i typed on the PC's keyboard after establishing communication.
What i tried and didn't work?1. I set the port's bps in Device Manager as 9600bps and set port settings for Hyperterminal 9600bps.
2. Port's bps in Device Manager is set to 115200bps and port setting for Hyperterminal to 115200bps
'****************************************************************
'* Name : Echo And Send.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2011 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 4/14/2011 *
'* Version : 1.0 *
'* Notes : PIC 16F877A echoes characters received by the PC *
'* : *
'****************************************************************
DEFINE OSC 20 ' Oscillator speed is set to 20MHz
TRISB = %11111111
TRISC = %10000000 ' RC.7 => USART RX pin set to input
TRISD = %00001000
PortC = 0
SPBRG = 129 ' Baud Rate = 9600
i VAR BYTE
CLEAR
RCREG = 0
' Variable definition
' ===================
'
TXSTA.2 = 1 ' High speed
TXSTA.5 = 1 ' Enable transmit
RCSTA.7 = 1 ' Bit 7, SPEN, Enable USART
RCSTA.4 = 1 ' Bit 4, CREN, Enable Continuous Receive
mainloop:
IF (PIR1.5 = 1) AND (PIR1.4 = 1) THEN ' Register RCIF is full & TXIF is empty
i = RCREG
TXREG = i
ENDIF
GOTO mainloop
END
The coding works if SPBRG = 10 (115200bps), Port's bps in Device Manager is set to 115200bps and port setting for Hyperterminal to 115200bps.
Ideas?