Hello,
I would like to transmit serial data using the integrated AUSART module in PIC16F88. THE PIC is directly connected to the PC.
Each time I start the transmission, the terminal receives some characters (not corresponding to what I send) and the RX counter doesn't stop just as if it would continue to receive datas.
It looks like a transmission speed error; I then tried all possible baudrates from 300 to 28800 bauds -> no improvement.
The datasheet indicates to set the TRISB accordingly. Except I/Os, I couldn't find other settings. Are there any?
Does someone have similar applications examples I could have a look at please?
Here is my code; unfortunately, it doesn't work well.
Code:
'PORTB.0 is button (INTCON use)
'PORTB.4 is LED
'PORTB.5 is TX (PIC fixed) connected to PC's SUB-D9 pin 2
'GND connected to PC's SUB-D9 pin 5
'On PC Micro Code Studio's Terminal set to 9600,N,8,1
OSCCON = %01100000 'Internal RC set to 4MHZ
TRISB = %00000101 'PORTB.0 & 2 are Inputs - all others are Outputs
RCSTA = %10000000 'Enable serial port (RB2=RX & RB5=TX)
TXSTA = %00100000 'Enable Transmit Bit
SPBRG = 6 'Set baudrate to 9600
Message var word
Message = 12345
MAIN:
if INTCON.1 = 1 then 'Start prog
INTCON.1 = 0 'Reset INT flag
high PORTB.4 'Led On = transmission start
TXREG = Message
low PORTB.4 'Led Off = transmission end
endif
goto MAIN
end
Bookmarks