Non-Polarized Serial Data
I have two lines of code that work but rejects the first serial transmission if the data is inverted. What is the best way for a SERIN statement to read data that is either inverted or not inverted?
SERIN RA.0, T2400, rb
SERIN RA.0, N2400, rb
Thanks?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
SERIN RA.0, T2400, rb
SERIN RA.0, N2400, rb
Thanks?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Comments
In general, I think you should be able to look at the idle state of the serial line and determine from that whether to expect true serial or inverted serial.
- Sparks
thx
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Assuming that the incoming data consists of long idle periods, detecting the idle state, as shown here, will work. But, in general, the requirement being imposed on you by the transmission device makes absolutely no sense. You really need to know ahead of time what kind of data you're receiving. But, absent any cues, like long idle periods, there's no way to know; and if you guess wrong, you'll end up receiving garbage.
Plus, I'm not even sure what you mean when you say that the transmitting device can send both types of data. Does this mean that it can change it's mind at any point in time and begin sending data of the opposite polarity? If so, an idle marking state will, all of a sudden, become either a bogus start bit, or the beginning of a long BREAK. If not, why can't you know ahead of time which polarity is being used?
I have to admit: I'm stumped by what seems to be a rather capriciously-inspired design requirement. I hope, for the sake of your project's success, that you can convince the designers of the transmitting device to make up their minds one way or the other.
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You can call it twice (be sure to place it inside a function if you do) and assign the return value of each instance to either the MSB or LSB of a previously defined Word variable. Thereafter you can treat the result just like any other Word variable!
- Sparks
P.S. If you wait a little while JonnyMac or Bean will probably come along and post the exact code to do this!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Something like “RBC = WordVariable” should accomplish what you have asked.
- Sparks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔