Actual Full-Duplex Serial Object
cgracey
Posts: 14,246
Everyone,
Attached to this post is a Spin object file you can download and view.
There are actually two files here: FullDuplexSerial.spin is the object (use NOTEPAD to view), while FullDuplexSerial.txt is an automatically-generated documentation file that is wholly a product of the .spin file. Within the Propeller.exe tool, this 'file' is generated on the fly, for viewing,·and usually not saved to disk. This way, one programming effort produces both code and downstream-user documentation. We've actually made our own TrueType·font for the Propeller tool which provides symbols for making schematics and waveforms right in your code comments (and, hence, in the automatic documentation file).
Anyway, this "FullDuplexSerial" object launches a COG in assembly language to perform background serial communications. Here's how you might use it in a higher-level object:
OBJ
· Com : "FullDuplexSerial"
PUB Go
·
· Com.start(31, 30, %0000, 115_200)
· Com.str(string("Hello World!", 13, 10, "How are you?"))
· repeat 1000···· 'Echo for a while
··· Com.tx(Com.rx)
· Com.str(string(13, 10, "Hasta la pasta..."))
· Com.stop
You could do this, too, if you wanted four of them:
OBJ
· Com[noparse][[/noparse]4] : "FullDuplexSerial"
You would then use them as 'COM[noparse][[/noparse]n].routine', where n ranges from 0 to 3. The only difference to your application size would be three more sets of variables, which amounts to 3 times 18 longs for this object. No matter where in your heirarchy you instantiate objects, the compiler squishes away redundant objects so that only one final copy of each exists in memory. Each instantiated object, though, gets its own variable space which is initialized to zero's. This keeps·every·object instance feeling·fresh and unique. It doesn't matter how many COGs might be concurrently mulling over·an·object's executable code, it's the variables that maintain the unique state of each instance.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chip Gracey
Parallax, Inc.
Post Edited (Chip Gracey) : 2/25/2006 10:02:59 PM GMT
Attached to this post is a Spin object file you can download and view.
There are actually two files here: FullDuplexSerial.spin is the object (use NOTEPAD to view), while FullDuplexSerial.txt is an automatically-generated documentation file that is wholly a product of the .spin file. Within the Propeller.exe tool, this 'file' is generated on the fly, for viewing,·and usually not saved to disk. This way, one programming effort produces both code and downstream-user documentation. We've actually made our own TrueType·font for the Propeller tool which provides symbols for making schematics and waveforms right in your code comments (and, hence, in the automatic documentation file).
Anyway, this "FullDuplexSerial" object launches a COG in assembly language to perform background serial communications. Here's how you might use it in a higher-level object:
OBJ
· Com : "FullDuplexSerial"
PUB Go
·
· Com.start(31, 30, %0000, 115_200)
· Com.str(string("Hello World!", 13, 10, "How are you?"))
· repeat 1000···· 'Echo for a while
··· Com.tx(Com.rx)
· Com.str(string(13, 10, "Hasta la pasta..."))
· Com.stop
You could do this, too, if you wanted four of them:
OBJ
· Com[noparse][[/noparse]4] : "FullDuplexSerial"
You would then use them as 'COM[noparse][[/noparse]n].routine', where n ranges from 0 to 3. The only difference to your application size would be three more sets of variables, which amounts to 3 times 18 longs for this object. No matter where in your heirarchy you instantiate objects, the compiler squishes away redundant objects so that only one final copy of each exists in memory. Each instantiated object, though, gets its own variable space which is initialized to zero's. This keeps·every·object instance feeling·fresh and unique. It doesn't matter how many COGs might be concurrently mulling over·an·object's executable code, it's the variables that maintain the unique state of each instance.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chip Gracey
Parallax, Inc.
Post Edited (Chip Gracey) : 2/25/2006 10:02:59 PM GMT
Comments
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Frankly, I'm scared by the Propeller. Self-modifying code!? Insert one wrong command and "What's it doing?!"
This is going to be a good chip!
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.startrek.com
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
That example I posted is about as extreme as Propeller programming gets, by the way. A typical user of that object would likely not do anything so complex in his code, as he would be using objects like this one to build his application. He doesn't have to look at anything too scary, if he doesn't want to - like my brother's boys, when something scary starts to get on TV they say "Change the channel, Daddy! Change the channel!"
Most people won't initially look under the hood, but when they're ready, everything will be there.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chip Gracey
Parallax, Inc.
First of all thanks for showing me all of your "toys" when I visited.
I see they took the chains off the door and let you out of the "bat cave".
It's nice to see some real programs in spin.
I know Pascal very well so I don't think it will be too much of a learning curve for me.
I can't wait to buy a dev. kit.
I want to try doing the CORDIC ATAN and HYP in spin (I hope you haven't already done them).
Great to have you join in the forus too.
Terry Hitt (Bean)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
"Ability may get you to the top, but it takes character to keep you there."
·
The assembly/compiler output describes the serial object of taking 156 longs program + 18 longs data.· This all gets loaded into a COG, starting at·the COGs $000 address.· What will be loaded to the cog for the balance of the 512 long footprint?·
I presume that the placement of the serial object is packed tightly into the global RAM.· Is the balance of the 512 long footprint the beginning of the next object(s) sequentially in RAM?·
Daniel
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chip Gracey
Parallax, Inc.
Since the compiler knows anyway, could it be made to emit the size of the assembly nuggets (perhaps global label to next)?· Perhaps even the cycle count too (thus I can avoid documentational effort of the comment notations seemingly common in well documented SX VPs)?
Uh, perhaps it just dawned on me--just count the assembly lines for the size.
Daniel
http://forums.parallax.com/showthread.php?p=573114
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
I have trouble using the the full duplex and extended serial object. I do have communication but all I get is gibberish on the other side.
I am experimenting with a propstick usb.
First of all I had to change the baud rate on the code above in order to get any activity at all. But even then I get things like random ascii. Same with bytes. I have tried using different pins, and ports other than the onboard usb, but same results. I have also tried all possible combinations of serial mode.
When sending byte 97 in mode 0 for example I get hex 99 9F or ascii ™Ÿ (in mode %0010 i get 99 9F or ™Ÿ[noparse];)[/noparse]. I mainly experiment at 9600.
Any ideas?
Thank you!
I am using the propstick usb with no extra hardware (just 5v in) with the onboard usb com (pins 30,31), but I have also tried using different pins into a rs485 transceiver and then into a 485 to usb com port (done this many times with other micros)
I have used a variety of codes using both the full duplex and extended full duplex object. But even the one above doesn't work.
I am using hyperterminal and com port toolkit.
I don't know what else information I could give you.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."
- Bjarne Stroustrup
Could you add the following to your FullDuplexSerial (and any others that may be relevant): (rather than a modified version) Didn't realise the age of this thread.
Add the following to your FullDuplexSerial object to make it easy to interchange the tv and fdx objects for output.
This permits code written for outputting to the TV object to be simply changed to the FullDuplexObject with only changing the initialisation call and not using the TV Pins assignment
Notice how simple the change is between outputting to the serial and tv.·The user code doesn't care if it is TV or FDX.
I presume there is also a VGA driver which has similar code.
Post Edited (Cluso99) : 9/12/2008 1:46:37 AM GMT
also squish the 2 objects into 1 copy in memory only after compilation?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
Thanks everybody!
I am using a uOLED-96-Prop which has an 8MHz crystal. The objects I have for serial comms are FullDuplexSerial and Extended_FDSerial, but I haven't deployed any code yet (hoping to tomorrow). The question is, if I specify _clkmode as xtal1 + pll16x and _xinfreq 8_000_000 will the baud rates in the serial comms objects (Serial.start) still be correct, or do I have to change something somewhere?
Sorry if this should be obvious, but I am a beginner with the prop and I'm still asking a lot of stupid questions at the moment!
Most library objects will adjust themselves for the system clock frequency specified by the _clkmode and _xinfreq values by using the clkfreq function. This is particularly true of the serial I/O, video/vga, and keyboard drivers. Note that, if _xinfreq doesn't match the actual operating conditions, the program timing will be off. The boot loader uses the _clkmode value to initialize the clock.
Here's where I'm at:
I purchased a few prop chips (actually uOLED-96-Props) from a UK supplier, but they weren't able to supply the prop clips or plugs. So I built the transistor-based serial to propeller schematic detailed on the parallax site (attached). With this I am able to communicate with the prop quite sucessfully, program / verify etc. I'm working with Extended_FDSerial and FullDuplexSerial, using the following spin code:
CON
_clkmode = xtal1 + pll8x
_xinfreq = 8_000_000
OBJ
comms : "Extended_FDSerial"
PUB Start
comms.start(31,30,0,2400) ' Rx,Tx, Mode, Baud
REPEAT
comms.tx("-")
(I also tried putting various pauses after the tx but this hasn't made any difference).
I checked the output from the prop with a scope and it IS sending the byte repeatedly as expected, and according to my measurements is at the correct frequency (1/2400 pulses per sec). However the voltage difference between 1 and 0 is only about 500mV at the computer's serial port, so I suspect this is the problem. I admit that I'm not certain what the port expects or requires
Has anyone used the atttached circuit to achieve comms at all? In the meantime, I found a prop clip and am awaiting the arrival of that, but I'd like to get out of my current quagmire!
- CF
If you look at the circuit diagram, you'll see that the output transistor uses DTR as a reference. Normally, this is at -3.3V when the serial port is open. If you are able to use this circuit for programming, that's probably the case. You may not be setting DTR when testing the output voltage of the port. Try connecting it to ground or -3.3V.
Your code looks ok and wouldn't affect the output voltage anyway.
I have downloaded the Parallax Serial Terminal (after I noticed it was there...) and this in fact works. I can communicate with the Prop over RS232. It seems that it was Hyperterminal's behaviour, along with that of a number of other terminal emulation programs, that were preventing this from working by setting DTR high and causing the odd functionality I observed. If there is a way of changing this DTR level using the software I have used till now, then I haven't been able to determine what it is. The Parallax terminal allows this to be set explicitly via a check box; voila, problem solved... why this sort of thing has to happen after several hours of not getting anywhere, followed by a post to this forum, I don't know. It could be old age.
However, I have on order a Prop plug which I think is a better more well-rounded solution - it had better be, they cost 45 bucks here in the UK with tax and postage!
- CF