multiple serial objects
FORD
Posts: 221
Hi,
I wish to use the parallax serial terminal (PST), and run it from 2 separate cogs at 2 different baud rates (on different i/o pins obviously).
I have 2 cogs running.
Can i run the PST object simultaneously in 2 cogs, using different baud rates ?
Meaning - will it run as a unique object in each cog ?
I'm guessing that it will, then I can just start the object in each cog at the desired rate.
Any help appreciated sincerely...
Cheers,
Chris
I wish to use the parallax serial terminal (PST), and run it from 2 separate cogs at 2 different baud rates (on different i/o pins obviously).
I have 2 cogs running.
Can i run the PST object simultaneously in 2 cogs, using different baud rates ?
Meaning - will it run as a unique object in each cog ?
I'm guessing that it will, then I can just start the object in each cog at the desired rate.
Any help appreciated sincerely...
Cheers,
Chris
Comments
I have no idea what you mean...
Does the serial object get loaded into each individual cog, if the code for that cog references the object ?
Sorry if its a dumb question...
In some cases, you actually require two objects to be compiled because of the way the objects work. In this case, you can copy the source (object) file with a new name i.e. copy FullDuplexSerial.spin to FullDuplexSerial2.spin and then define in your code as follows...
There is also a 4port serial driver in the obex too.
Meaning - will it run as a unique object in each cog ? Yes
Does the serial object get loaded into each individual cog, if the code for that cog references the object? Backwards. The object references the "cog code".
All you need to do is to create your object for the second serial port, and start it up.
Both SRLM and Cluso99 showed you how to use multiple instances of a serial driver.
Cluso99 also mentioned a four port driver. I think Tracy Allen's four port object is currently the best. He fixed some of the framing and flow control issues of earlier versions.
Multiple instances can be used of most objects. There are a few objects which use variables in the "DAT" section that don't work well when running multiple instances but these are kind of rare.
A four port serial object is just a little harder to use (barely) than single port objects, but it saves on cogs. IMO, it's well worth the effort of learning to use one.
The four port object uses one pasm cog to service up to four serial ports. It's HUB footprint is somewhat larger, so if you have cogs to spare it may be better to do two instances of PST. The four port object also supports flow control if you need it, and it rejects bytes that cause framing errors. (Thanks again for the plug, Duane!)
A note about what cluso99 said about creating multiple instances of spin objects. It is not sufficient to simply rename the file. The compiler is smart enough to recognize that they are the same. You have to change at least one byte in the code, for example one extra DAT variable. Normally you will want only one instance of PST spin methods.
Regards,
Chris