Shop OBEX P1 Docs P2 Docs Learn Events
Serial Parameters — Parallax Forums

Serial Parameters

StampUSRStampUSR Posts: 48
edited 2005-07-14 04:21 in BASIC Stamp
Is it possible to use Serin/Serout with serial parameters other then 8N1 and 7E1?

For example Odd parity with 8 bits and so on? I need to connect to equipment that has other then those two parameters above.

TIA!

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2005-07-12 15:03
    Nope, SERIN/SEROUT only support 8N1 or 7E1. Sorry.

    Even the 8300 external SPI-based UART does not do 8-odd-1. PC-based UARTS do this all the time, of course, but to use one with the BS2 you'd need an 8-bit bus. Which is not impossible.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-07-12 15:22
    StampUSR -

    You may want to integrate a Maxim MAX-3100 UART into your design which will permit nearly any kind of RS-232 parameters you might wish to incorporate, now or in the future. Here is a link to the product: http://www.maxim-ic.com/quick_view2.cfm?pdf_num=1731 .
    It also incorporates an 8 word FIFO buffer which can be quite helpful at higher baud rates.

    Here is a link to some PBASIC Stamp code to drive it, thanks to Dr. Tracy Allen:
    http://www.emesystems.com/BS2IrDA.htm . Although that code utilizes the IrDA facility of the MAX-3100, it will show you how the registers are loaded and used, which is the most important aspect of utilizing it. Good luck with it, I've found it most helpful for unusual RS-232 applications.

    Regards,

    Bruce Bates
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-07-12 15:36
    Nope, even the MAX-3100 only does 8N1 or 7E1. Read the documentation, your mileage may vary.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-07-12 15:59
    Allan -

    That's certainly not the way I interpret Table 5 where they discuss 7, 8 and 9 bit data transmissions, as well as whether parity bits will be sent or not. I'm NOT claiming that it will calculate the parity for you, just that it's capable of setting it, at your instruction. You may well have to calculate your own parity and set the bit accordingly.

    Regards,

    Bruce Bates
  • StampUSRStampUSR Posts: 48
    edited 2005-07-12 16:23
    I was afraid of that... I will look into the MAX3100 and see what I can do there.

    The vast majority of the time I just need to read data in this configuration, not write it. I'll have to see what the BS 'sees' as received data with the parity wrong? Maybe I'll get lucky and it will still extract the data bits properly and reframe based on start/stop bits? (I don't think I'm that lucky though......)

    Any way around this internally with a BS2px? I saw an old message in the forum about 'bit blasting' but no real explanation of that? I assume that is something like sending the data 'by hand' using the pulse in/out commands?

    Thank!
  • StampUSRStampUSR Posts: 48
    edited 2005-07-12 16:24
    Bruce,

    That is how I read it too in the Max3100 sheet. It does mention that it won't calculate Parity, just that if you have the parity bit enabled it expects an extra bit that it sends as parity.

    Anyone used a Max3100 know for sure?

    Thanks!
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-07-13 00:34
    I stand corrected -- the 3100 won't calculate parity at all, but it WILL let you 'set' a parity bit. Now, you'll have to figure out what that parity bit is supposed to be in PBasic code, I suppose.

    However, if you're only recieving, and you don't care about the parity bit, it should work fine.
  • StampUSRStampUSR Posts: 48
    edited 2005-07-13 15:48
    " if you're only recieving, and you don't care about the parity bit, it should work fine."

    I tried reading from a 8O1 source.

    It works... sort of. It looks like I get some data corruption in the form of bytes being changed in value. I didn't spend a lot of time with this but if it is consistant I can deal with it. I am not sure what the pattern of the changed bytes is yet.

    If it isn't consistant I'll have to either go with a UART or move to a processor that can handle different serial port settings directly. Will take a look at the SX chips to see what they can do.

    Hopefully I can work around this since I have 25 BS2px's on the way....

    Anyone know if the limited comm settings are in the editor/tokenizer, the basic interpretter on the chip or is it a limitiation of the actual processor on the chip? It would be great if it was an editor/tokenizer issue as it potentially could be changed.

    Thanks!
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-07-13 18:12
    Yes, the PIC chip can be programmed to 'bit-bang' (or 'bit-recieve') just about any format of serial RS232 data. Parallax chose the 8N1 and 7E1 as the ones they would support in their PBasic language. However, I understand it can be quite code intensive, and the code involved is 'burned' into the PIC chip on the BS2.

    I don't see them changing this code at this late date, but the answer is that it is a limitation of the Basic Interpreter on the chip.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-13 18:33
    Engineers are always faced with choices, and when the BASIC Stamp was designed it was important to maximize the available code space with features that would positively impact that greatest number of customers. To that end, there was just no room to support every possible serial format; 8N1 and 7E1 have the most use and hence were selected.

    As may have been mentioned before, we have a compiler for the SXmicro (the core of several BASIC Stamps) that allows you to do what you want. We're not going to change the BASIC Stamp in regards to sERIN/SEROUT, so another tool or external accessory may be required for your project.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • StampUSRStampUSR Posts: 48
    edited 2005-07-13 23:09
    "As may have been mentioned before, we have a compiler for the SXmicro (the core of several BASIC Stamps) that allows you to do what you want. "

    I am looking at the SX/B compiler and it looks even more limiting in that it only supports 8N1. Since there is no interpreter chip here I would definitly like to see more flexibility with this setup.

    Thanks!
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-14 04:21
    With the SX and SX/B you can do whatever you want. The built-in SERIN command is an 8N1, but you can write your own UART code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.