TAQOZ ROM FORTH - Using Smartpins to transmit and receive asych serial data
I have been experimenting with TAQOZ ROM Forth to read serial data from SDI-12 sensors and now have a working bit-bashed serial data program for transmitting and receiving data. Developing the program has been great fun and has taught me a lot about the P2 and how to use TAQOZ.
I'd like to simplify the program using Smartpins in asynch serial mode. The transmit side is working thanks to Peter and Bob's examples in 'The Bit Bashers Guide to the Parallax P2', where there are examples of transmitting serial data, but I am struggling to work out how to receive serial data using Smartpins.
Does anyone have any experience of receiving and handling serial data with Smartpins using TAQOZ ROM FORTH?
Thanks, Pete
Comments
Hi Peter,
I cannot help you directly. But I am trying to learn about Smartpins myself with Taqoz. At the moment I try to do this this way: Use Taqoz 2.8 from SD-card. It has got the inline assembler. So it should be possible to move PASM code from the other examples to Taqoz.
In your case I would start from jm_fullduplexserial.spin2 , which is contained in the download of Propeller Tool.
Good luck!
Christof
Hi Christof,
Many thanks, I appreciate your support. We are both thinking along the same lines: I have Taqoz 2.7 running on SD-card (haven't found 2.8) with TIA and have been trying snippets of PASM code (thanks to SuperBob's and John Titus's docs). I'm still learning TIA code/syntax and mostly my code crashes Taqoz
I initially used JonnyMac's jm_fullduplexserial object for a Spin2 version of my SDI-12 program, which works well (except not being able make the RX non blocking - due to lack of understanding of Spin2 on my part, not the serial library). However, the challenge is to get a version running in Taqoz FORTH using Smartpin TX and RX.
I'll look again at the PASM RX code in jm_fullduplexserial.spin2, try it out with the TIA and report back...
Thanks,
Pete
Hi Pete, Taqoz 2.8 is in the ZIP from April here: https://sourceforge.net/projects/tachyon-forth/files/TAQOZ/binaries/
Hi Christof,
Many thanks, I'll have a go with a new SD card.
Making some progress with Smartpin Async RX. I've got a minimal TX/RX test program working just using the Smartpins.
I found some useful routines in Peter J's PS2 keyboard code that helped me understand how to initialise Smartpin in async RX mode and how to retrieve characters.
I'll post the code after a bit more experimenting.
Pete
Hi Christof,
I worked out how to use a smartpin to receive serial data in Taqoz ROM FORTH (thanks to Jon Titus's smartpin document).
Please see Taqoz words below to initialise/enable smartpin async mode and to receive a serial character.
The CLKSET routine sets CLKHZ to the actual measured RCFAST frequency (~25.5 MHz) which then allows normal baud rate values to be used.
e.g. If CLKSET is not used, the BRATE value would need to be about 1053 instead of 1200. To measure the P2 clock see 'The Bit Basher's Guide..' page 15.
Here is a demo program that generates a serial data message in the background (i.e. running on cog 1) which is received by a serial data routine running in the foreground.
It's great how the P2 cogs can test itself! The RX serial routine to be tested can run on one cog and the TX routine can independently send serial data to the RX routine from another cog.
Join the serial TX output pin on P16 to the RX input pin on P18 via 1K Ohm resistor. Type GO to start the demo and any key to stop it.
It's been great finding out how smartpins work, I've a long way to go yet but I hope these very basic serial routines may be of interest to others too.
Thanks for the encouragement,
Regards,
Pete
Thanks for this @Peter_F , this plugs a big gap in serial comms - Bob
Great! Thanks for sharing!
Hi Bob,
Thanks, I appreciate your help too, your Bit Basher's Guide is always open on my desk!
Please use/edit the RX code if you think you might need another serial comms example.
I have been using the TAQOZ ROM Forth, because it supports smartpin async serial at the low
baud rates I want to use (ie 1200 baud for SDI-12 sensors) and is so easy to program using FlexProp.
Cheers,
Pete
There is a potential flaw with the serial input code SDRX - if no chr is ever received (e.g. the connector is unplugged), the following code will never exit:-
Better is to have a serial input word SDRX-TO that will eventually timeout if no chr is received (requires PASM loaded):-
I had a need for a timeout, as a means of synchronising the receipt of a stream of longs from a windows p.c. When timeout occurs, taqoz will know that a new long is about to be received as four bytes.
N.B. When testing serial input routines out, you may not have enough time to display debug results. e.g. If a serial input is running at full speed at 921600 baud, you will miss serial input data if you try to display stuff on the user terminal, because it also runs at 921600 baud! To fix that, you might:-
1. Introduce a timed gap between serial input chars, assuming you have control of the source
2. Change the serial input baud rate to something low like 9600 baud - that would give a little time for debug display at 921600 baud in between serial input chars
3. Pass filtered data to another COG for display, via a queue (maybe)