Creating text file using SPIN
Hi everyone,
I am new to SPIN and do not have much serial communication experience either. I am trying to create a text file and write data onto it. I only want to write numerical values and am using the full duplex serial communication object file. I am using a SPIN microcontroller. Can anyone help me with a simple code? Thank you for your time.
I am new to SPIN and do not have much serial communication experience either. I am trying to create a text file and write data onto it. I only want to write numerical values and am using the full duplex serial communication object file. I am using a SPIN microcontroller. Can anyone help me with a simple code? Thank you for your time.
Comments
To output a single character, use .tx
To output a numeric value in decimal, use .dec
To output a constant string or a constructed dynamic string, pass its address to .str
The string has to be terminated by a zero byte.
I believe the Propeller Serial Terminal can save the text content of the display window to a file. Check the documentation there for details. It's a manual operation, but may be enough for your task.
welcome to the forum.
Writing received data to a textfile on a PC is not a matter of the serial link between the propeller-chip and the PC.
This has to be done by the receiving software. FullDuplexSerial does nothing else but transferring data.
The meanings of the data = how the data is interpreted is a different thing. This interpretation has to be done by the receiver.
As a first test you can use br@y's terminal https://sites.google.com/site/terminalbpp/
This is a terminal software for PC that has the same functions as PST.EXE but goes beyond that.
It has a script-interpreter that allows you to code in a PASCAL-style conditional interaction with the propeller-chip
Of course you can use any kind of programming language that can open/close COM-ports.
You have to provide more information of what you want to do in the end. How much data? What kind of data?
It highly depends on your requirements which solution is suitable for your application.
best regards
Stefan
''HelloFullDuplexSerial.spin
"Test message to TERMINAL"
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
Debug: "FullDuplexSerial"
Var
Long count
PUB TestMessages
''Send test messages to Parallax Serial Terminal.
Debug.start(31, 30, 0, 57600)
repeat
Debug.str(string(" This is a test message!", 13))
waitcnt(clkfreq + cnt)
count:= count +1
debug.dec(count)
Open the Windows terminal and when prompted enter a name.. "test", ignore telephone numbers. Make sure you are using the correct Serial Port, usually port 1 thru 4. If you only have 1 serial port available. Use the same port as you use to connect to the prop.
If using only 1 port you will have to run the Prop program prior to connecting to TERMINAL.
Set the Bits per second (baud to the same as the prop, 57600 in this example) Data bits 8, Parity None, Stop bits 1, Flow Control Hardware.
Now you can open the Prop Tool, load the above program to ram, click the Terminal and then click Wait for a Call. You should see the results of Prop output in the terminal display. You can use the additional options of the TERMINAL to save to a file or even transmit.
Hope this helps.