I agree with Mister_E and I would suggest using his pic multicalc application.
Code:
' From pic multicalc
RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $20 ' Enable transmit, BRGH = 0
SPBRG = 17 ' 1200 Baud @ 20MHz, 0.0%
SPBRGH = 4
BAUDCON.3 = 1 ' Enable 16 bit baudrate generator
' Your loop code like this:
pTxData VAR PORTC.6
RCIF VAR PIR1.5 ' EUSART Recieve Buffer Full
MainLoop:
WHILE RCIF = %1
SEROUT pTxData, 5, [RCREG]
WEND
GOTO MainLoop
This was just something whipped off the top of my head, so no promises... Some things to note are:
Make sure you have something to check your transmission was successful.
Pay attention to your modulation. I use transmitters that use OOK for small data applications. Then use the serout to transmit so I can invert the data. On the OOK transmiter the normal marking state of a UART is 1. This causes it to constantly be transmitting. Thus why I invert with the software transmission. If you recieve inverted data while using the hardware UART, then you must have a hardware inverter (or transistor inverter) setup.
Also remember you'll probably want to send some sort of transmission start string to signal you are about to transmit. Also and end transmission string.
If you are using a superheterodyne receiver sometimes it helps to train it by sending a few $55's.
A crystal or resonator is more accurate in buad rate generating than the internal osc.
Hope that helps, I kinda was distracted while I wrote this post.
-Nemesis
Bookmarks