I was just trying to send continuous stream of letter 'G' from my PIC MCU (PIC18F452) to my laptop.
Here is my assembly code that i am using :
#include <p18f452.inc>
CONFIG OSC=XT,WDT=OFF,PWRT=OFF
ORG 0H
MOVLW D'12'
MOVWF SPBRG
MOVLW B'00100000'
MOVWF TXSTA
BCF TRISC,TX
BSF RCSTA,SPEN
OVER MOVLW A'G'
S1 BTFSS PIR1,TXIF
BRA S1
MOVWF TXREG
BRA OVER
END
I design the circuit in proteus and simulate it with realterm and hyperterminal i get the desired output.
But when i try to implement the hardware i face some problem. I do not get output at Realterm just when i connect my source. But at the instant i remove the source (unplug just ground or live wire) i get the output (G string).
Can any one tell me what is the problem?
Devices that i use:
01. PIC18F452
02. 8MHz Crystal Oscillator,
03. MAX232 with five 10uF capacitor
04. USB to RS232 cable.
Here is my connection diagram:
Best Answer
If the PIC is a 3.3V one you might find the MAX232 is borderline working with the levels on its TX pin. You might need to use the 3V version of the MAX232.
Otherwise you need to put a digital oscilloscope on pin3 of your P1 and check if you have your data there, if yes measure the width of a bit and make sure the baud rate is what you are expecting. (1 divided by width of one bit in seconds will give you close to the actual baud rate).
If no data, then check on pin 25 of U1 and see if you have data there. If not there might be a software bug.