Dwayne, thanks so much for your input. I learned how to read a serial signal with a scope, and now have a much better (if not more confusing) view of what's going in and out.
Here's where I stand, and unfortunately it's more confusing than ever. Good news is I can show you what's going on more clearly now.
Again, I started with a fairly clean slate to work out these issues. Here's my current code:
Code:
@ DEVICE INTRC_OSC, LVP_OFF, WDT_OFF, MCLR_OFF
define OSC 4
'Baud CON 33581 ' 1200 baud, true, N,8,1
Baud CON 49965 ' 1200 baud, inverted, N,8,1
'Baud CON 19697 ' 300 baud, inverted, N,8,1
serialData VAR byte
flip var byte
serialHigh VAR byte
serialLow VAR byte
'USART Defines:
define HSER_RCSTA 90h
DEFINE HSER_BAUD 1200
TRISB.1=1
TRISB.0=0
HIGH portb.3 'we saw it, so light up LED4
pause 1000
low portb.3
MAIN:
hSERin 5000,START,[serialData]
SEROUT2 PORTB.0,baud,[serialData]
START:
'Do normal program stuff
goto main
As you can see I tried using the USART in the '628A and it seems to be working... keyword "seems"...
OK, here's what's happening. I'm using HyperTerminal. I type a letter and would expect the same letter to come back since I'm echoing the data directly back through the serial port. Of course this doesn't happen. Here's an example:
I type the number "1" and I get "g" in the terminal output window. Here are the waveforms. I'll use ^ for a high and . for a low:
Input "1": ____^.^^^..^^___ = 00110001
Output "g": ____^...^^..^___ = 01100111
The numbers are obviously related, but its not straight forward. If you invert the output bits and shift left one bit then you get the input bits. This has got to mean something but I have just no idea.
Any guesses as to what's going on? I feel like I'm close here... I'm just not smart enough to figure out what's going on.
Thanks again to all who've replied!
-Jeff
Bookmarks