serial wordsize of 9 bits?

serial wordsize of 9 bits?

Post by Martijn van Bu » Sat, 18 Aug 2001 23:25:43



Hello.

I have a question regarding programming the serial port (under Linux-2.4.2).
I'm working on an application with a (remote) 8051-derived microcontroller.

A 8051 has a nice feature, called "multi-processor mode". In this case,
the wordsize is extended to 9 bit, and an interrupt is generated whenever
this 9th bit is 1. This can be used to flag the beginning of a message
or frame, or whatever. I'd like to use this feature from a Linux-box,
but I'm having some problems with it.

The posix serial API doesn't support a 9N1-data format. However, it would
be possible to have the PC use an 8-bit wordsize, and use the parity
bit to send out the 9th bit. 8S1 would result in the 9th bit being 0,
8M1 would make it 1. On the incoming side (the 8051 sends out 9 bit
as well), the parity could be enabled but ignored (since it's not a parity
bit in the first place).

Since this 9th bit doesn't carry any information (except 'beginning of a
frame'; the data itself is 8-bit wide), the overhead from that would be
acceptible. However, this means that I have to be able to *exactly* control
which bytes are transmitted as 8S1, and which ones as 8M1. This probably
means that I have to disable the FIFO, or a way to *reliably* drain it.

Can I safely use the TCSETSW IOCTL for this task? It doesn't seem like
this can be done with POSIX tc* functions.

Any suggestions / hints would be greatly appreciated.

Kind regards,

Martijn.
--

         Geek code: G--  - Visit OuterSpace: mud.stack.nl 3333
   Kees J. Bot: The sum of CPU power and user brain power is a constant.

 
 
 

serial wordsize of 9 bits?

Post by Jan Pantelt » Sun, 19 Aug 2001 04:17:32


If you are using a 8051 multi processor setup (and address flag is bit 9), then
why not use a separate 8051 on the serial port to drive these?
Then you can choose any which protocol to talk to that one.

Dedicated hardware is always better.
Regards
Jan

 
 
 

serial wordsize of 9 bits?

Post by Grant Edwar » Sun, 19 Aug 2001 04:27:24



> If you are using a 8051 multi processor setup (and address flag
> is bit 9), then why not use a separate 8051 on the serial port
> to drive these? Then you can choose any which protocol to talk
> to that one.

I think you can get 9-bit capable serial boards for PCs.  Do a
deja search on comp.arch.embedded -- the topic comes up pretty
regulary there.  Whether there are Linux drivers for such
boards is another problem.

Quote:> Dedicated hardware is always better.

Wouldn't it be easier to just build a dumb 9-bit serial board?

--
Grant Edwards                   grante             Yow!  It's NO USE... I've
                                  at               gone to "CLUB MED"!!
                               visi.com            

 
 
 

serial wordsize of 9 bits?

Post by Grant Edwar » Sun, 19 Aug 2001 04:43:13




>> If you are using a 8051 multi processor setup (and address flag
>> is bit 9), then why not use a separate 8051 on the serial port
>> to drive these? Then you can choose any which protocol to talk
>> to that one.

> I think you can get 9-bit capable serial boards for PCs.

Here's one source:

http://www.cimetrics.com/www/Product/Specifications/rs_hdwe-nbs10.html

They only list drivers for Win 3.1/95/NT.  It's a standard
Intel 82510, so there might already be a Linux driver that
could be hacked up to do what you need done.

--
Grant Edwards                   grante             Yow!  Yow! I like my new
                                  at               DENTIST...
                               visi.com            

 
 
 

serial wordsize of 9 bits?

Post by Jan Pantelt » Sun, 19 Aug 2001 07:21:00





>> If you are using a 8051 multi processor setup (and address flag
>> is bit 9), then why not use a separate 8051 on the serial port
>> to drive these? Then you can choose any which protocol to talk
>> to that one.

>I think you can get 9-bit capable serial boards for PCs.  Do a
>deja search on comp.arch.embedded -- the topic comes up pretty
>regulary there.  Whether there are Linux drivers for such
>boards is another problem.

>> Dedicated hardware is always better.

>Wouldn't it be easier to just build a dumb 9-bit serial board?

Perhaps, shift register... (btw Intel used to sell such a 8051 board I think,
they had this whole development setup).
The point is the 8051 external could talk to a standard serial port.
So no need to make an ISA card or the like, or open the PC.
Of cause a shift register could do the same.. just need more data for
the setup.
To do it in software on an IO pin will not work reliably if there is
a lot of load on the system.
Oops I forgot, I would use a PIC 16F84 nowadays, flash programable, will do.
I even have one here I programmed to mimic 3 complex i2c chips.., good stuff.
Regards
Jan
Quote:

>--
>Grant Edwards                   grante             Yow!  It's NO USE... I've
>                                  at               gone to "CLUB MED"!!
>                               visi.com            

 
 
 

serial wordsize of 9 bits?

Post by Jan Pantelt » Mon, 20 Aug 2001 00:06:59


Actually I want to mention something technical here.
If you want to connect external hardware to a multi tasking system
like Linux for example, and avoid the already used serial port (mouse /modem
etc), you could get a second par port card.
And then use 3 bits on the par port card to talk IIC* protocol to a whole lot
of PICs who pose as IIC slaves, or real IIC chips of cause.
The advantage of using IIC is, that because of the data and clock lines /
system, you can HALT the communication (for indefinitely if you do it right)
and then continue where you was.
In such a case you need no interrupt driven drivers, and can do just IO from
the application.
This is what I am doing, I have a separate par port card, with 3 pins for
slow IIC, 3 pins for fast IIC, and a whole range of IO boxes connected to it.
If done right IIC will work to several meters (cable capacitance and pull up
resistor value are limiting factors).
And par port driver ability of cause.
Already in '87 or so, when Philips came out with the IIC protocol, I did it
with external drivers in a building over several hundred meters with more
then 50 remote receivers.
Given the complexity of USB, simple making IIC external, can have a lot of
advantages.
mmm just wanted to say that :-)
Regards
Jan

*IIC = Philps i2c 2 wire serial protocl clock + data.

 
 
 

serial wordsize of 9 bits?

Post by Martijn van Bu » Tue, 21 Aug 2001 19:42:05


It occurred to me that Jan Panteltje wrote in comp.os.linux.development.system:

Quote:> If you are using a 8051 multi processor setup (and address flag is bit 9),
> then why not use a separate 8051 on the serial port to drive these?
> Then you can choose any which protocol to talk to that one.

Well, that doesn't change much. I have to program the target 8051 anyway,
so I'm completely free to choose my own protocol anyway. It just sounded
like a feature which I would like to use. If it's not possible, that's
fine with me. Adding a second 8051 doesn't strike me as something
very useful.

--

         Geek code: G--  - Visit OuterSpace: mud.stack.nl 3333
   Kees J. Bot: The sum of CPU power and user brain power is a constant.

 
 
 

serial wordsize of 9 bits?

Post by Martijn van Bu » Tue, 21 Aug 2001 19:58:37


It occurred to me that Jan Panteltje wrote in comp.os.linux.development.system:

Quote:> If you want to connect external hardware to a multi tasking system
> like Linux for example, and avoid the already used serial port (mouse /modem
> etc), you could get a second par port card.
> And then use 3 bits on the par port card to talk IIC* protocol to a whole lot
> of PICs who pose as IIC slaves, or real IIC chips of cause.

Been there, done that before. I wrote a couple of I2C drivers for Philips.
Problem is that you *need* slaves with a hardware implementation, if your
master is software-based. I2C hardware is relatively expensive, and there's
little reason to use it if you can use the serial port.

You can't have a software-slave, if you want to have acceptible bitrates,
which means that the master (== the linux box) has to poll wether things
are going on. The whole idea is about a remote-controlled mp3player. The
current implementation uses a similiar protocol, using only shift registers
at the remote end, but this means that the PC has to poll wether there's
a button pressed, while I like the remote control to just *tell* me there's
something going on. Apart from that, it requires a lot of CPU intervention.
I wanted to use a 8051 via RS232, because I do have hardware support in
that case.

Quote:> If done right IIC will work to several meters (cable capacitance and pull up
> resistor value are limiting factors).
> And par port driver ability of cause.

I2C was designed for short cable lenghts. However, there are transceiver
chips, which turn I2C into a current-driven thing. Works like a charm -
I've used cables of 50m.

Oh, Linux 2.4 comes with kernel drivers for a bit-banging I2C interface
on the parallel port, by the way.

I have a Fast AV-Master laying around, which isn't supported by Linux
anyway (And which will probably never be, due to Dazzle refusing to
release info about the only unknown ASIC on that darn card). I did
write a halfway-finished driver for the I2C port of the on-board
multimedia controller, though. Bit of a shame to abuse a video capture
card as a I2C master, though ;)

--

         Geek code: G--  - Visit OuterSpace: mud.stack.nl 3333
   Kees J. Bot: The sum of CPU power and user brain power is a constant.

 
 
 

serial wordsize of 9 bits?

Post by Jan Pantelt » Wed, 22 Aug 2001 00:14:54




Quote:>You can't have a software-slave, if you want to have acceptible bitrates,
>which means that the master (== the linux box) has to poll wether things
>are going on. The whole idea is about a remote-controlled mp3player.

Well, I agree with most of the other things in your post, but here I beg
to differ a bit.
I am using PIC 16F84 at 10 MHz, and it does a neat simulation (if you want
to call it that) of a 50 kHz iic bus.

I am interupting the PIC (iic clock on port pin change interrupt).
This allows for very fast handling.
If using for example to replace a pcf8574 8 bits IO expander, you can do it.
I had a 2 board double sided design with 3 PCF8574, 4 ttl coparators,
2 12 bit counters, and some other stuff (video).
Now it is reduced to 1 16F84, and the video stuff on one single sided euro
card, with additional funcions in the PIC (also for self test) and MUCH less
power consumption, and I added additional hardware in the free space.
And in my software IIC slave I can choose my own addresses and sub addresses
too.
For example this PIC also does a frame counting at the same time (40 mS
period).
The frame counter will not get upset by the iic communication interrupt,
as it is polled, it will just increment (with a small jitter) when the
IIC clock change interrupt routine returns and the frame input changed.
And remember I am doing it at 50 kHz with 3 IIC chips simulated, and input
and output, and some processing.
And last but not least it saves a whole lot of money, 1 PIC is much
cheaper then all those IIC chips and TTL stuff.
And it allows me to read protect my PIC so no one can just copy it.
And even a single PIC emulator si sometimes cheaper then the same IIC chip.
So, do the numbers, you will see at 10 MHz PIC clock you can do a lot!
Regards
Jan

 
 
 

1. How do you increase the wordsize in csh?


This is not word size, but the size of an argument list.
This particular limit cannot be altered without hacking the
csh source.  It's a manifest constant defined in sh.h
(GAVSIZ).

Chet

--
``The use of history as therapy means the corruption of history as history.''
        -- Arthur Schlesinger


2. Slow printer

3. local serial printer prints at wrong baud rate or wrong # bits

4. problems using Linuxthreads & setscheduler

5. Serial link is not 8-bit clean

6. Netscape 1.12 Connects but doesn't get anything

7. PPPD: "Receive serial link is not 8-bit clean"

8. Translating file names. Maybe this is a perl question.

9. serial link is not 8 bit clean

10. Receive serial link is not 8-bit clean

11. old digiboard pc/8 8 bit serial card

12. PPPD Problem - Serial link is not 8-bit clean?

13. Serial line not 8-bit clean (all of a sudden)?