SX52 with 75 MHz TTL oscilator
My question is, can I reach a 1 M baud rate using this setup. Anybody have any ideas of how stable the data transmission at these baud rates would be. If I can get the SX chip to keep up with the Propeller chip at that rate, I am thinking of using it for a testing purpose.
Thanks
Ray
Thanks
Ray
Comments
at 75 MHz, you would need to call the interrupt routine that handles the serial transmission for 1M Baud every 75th clock cycle, so this is a reasonable value, and I think the transmission will be stable enough.
When you also want to receive asynchronous serial data at that baud rate, things become more problematic as you normally should poll the serial input line at least three times faster than the baud rate. This would mean that the ISR should be invoked every 25th clock cycle. This does not leave much room for instructions inside the ISR, and "steals" away a lot of exeution time from the main program.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
Thanks
Ray
I'd say you are well within the realm of reasonableness.
Actually, I have been able to get the SX to run at 10 Mega bits per second very reliably (like, never an error) with a 50 mHz resonator, so 1 Mbit aught to be a breeze.
Keep on experimenting... you'll find the answer! Holler if you want some pointers.
Cheers,
Peter (pjv)
Post Script:
Um, I now see your reference to SX/B, and I'm not sure that can cut it. SX/B you see is a blocking language structure; that is while you are waiting, not much else can be done deterministically, and that's a problem. All of my work has been in assembler, working with multiple "simultaneous" threads, and that method DOES give you the speed required. Perhaps someone will prove me wrong and manage 1 Mbit with SX/B, but I believe it will be a real challenge!
Post Edited (pjv) : 1/14/2008 1:12:58 AM GMT
I've attached a hybrid program that uses SX/B as the framework, is non-blocking, and has lots of assembly mixed in for speed -- some of that code borrowed from you, PJV!
[noparse][[/noparse]EDIT] Found a small bug in an assembly section; didn't cause the program to fail, but could have....
Post Edited (JonnyMac) : 1/15/2008 1:37:48 AM GMT
Aren't those state machines a great way to deal with sequential issues !!!!
In fact, I have developed the concept quite a bit further to the point where a real time sequencer reads a string one byte at a time using the iread instruction, and interprets the byte as the address of a tiny atomic piece of code (such as one of many states), and then jumps there to execute it. The string may also concecutively have other parameters such as delay time values, all as required by that piece of code. When the piece has finished running (it is always very short), then it returns control to the scheduler which reads the next byte as the address for the next piece of code. Each piece of code knows how many parameters to read out of the string.
In its simplest view, the string is simply a list of address names for the small executables, interspersed with other parameters as required.
This mechanism lends itself well to multiple co-operative threads, each non-blocking, and readily implemented. It lets you think about the tasks to be done, and relieves one somewhat of the details of interaction between threads.
It works particularly well for cases where you have to fire off serial configuration data such as a list of "AT" commands to a modem or a cell phone. The byte string holds the virtual UART state addresses, as well as the data to be sent, and the delay times in between the AT commands, responses permitted etc. Naturally one can jump from string to string, or loop any number of times within a string.
Great fun!
Cheers,
Peter (pjv)
I am -- albeit slowly -- starting to get it. It's really is a mind-set change, but as I've had a few successes converting somewhat linear code to state machines, and gaining improved performance in the process, I'm working harder to develop more code that way, even when using SX/B as a framework. I would love to see more of the code examples that you're free to share because I find that studying the successes of others is a big help.
I did find one of your examples that had a state-driven UART but was not able to get it to work for my project (yet); it seems like it would perform faster than the standard VP code I'm using... am I correct?. I have a lot of friends asking me to help them with DMX projects and I'm trying to squeeze the most out of the SX (and myself) to make it happen for them.
Thanks for all your great suggestions and tips,
Jon
I would also like to see the state machine UART code, how is that different from a VP code. So many questions, too few people to answer them.
Thanks
Ray
A State Machine has a set of defined states - the machine will, at any one time, be in one of the states. It cannot be in more than one state and it cannot be in a state that has not been defines (well we hope not - if it is then we didn't do things right).
It changes states only under defined conditions. I Traffic light is a very simple state machine. The states are Red, Yellow, and Green. It changes from Red to Green to Yellow and back to Red based on time. It never changes from Red to Yellow, or from Green to Red, or from Yellow to Green.
Lots of others have already spent lots of energy on this topic. Here are a few:
WIKIPEDIA http://en.wikipedia.org/wiki/Finite_state_machine
UML Tutorial: Finite State Machines http://www.objectmentor.com/resources/articles/umlfsm.pdf
Finite State Machines; Making simple work of complex functions http://www.microconsultants.com/tips/fsm/fsmartcl.htm
Want more? Google "Finite State Machines" and you'll get more than you want.
FSMs are one of the most powerful tools for hardware, software, or system design. IMHO
Doug
If you look at Jon's code, you'll see that there are a series of things that the DMX receiver has to do sequentially in order to handle DMX data. It starts with state 0, which causes the program to basically loop around and around checking to see if a DMX break has occurred. If it hasn't, the code loops back to where the state is checked which, determinging it's still in state 0, jumps to see if a DMX break has occurred, etc. etc. At some point (presumably), a DMX break will occur. The code will handle that break and then set the state variable to "1". Now the code check to see if the conditions have been met to handle state 1. IF not, it goes back to the state checking code, sees it's still in state 1, and then jumps to the code that handles state 1. This repeats until state 1 occurs and is handled, at which point the state is set to 2.
You can probably see where this is going. The code is either looking to see what state it is in and jumping to the appropriate handler, or the handler for a state is executing. If the handler executes and the state's work doesn't happen, then the code just goes back to see what state it is in. If the state's code does happen, then the state counter is set to the next state, lather, rinse, repeat.
Thanks,
PeterM
I can only agree - state machines can make programming a lot easier. I used them in my SX code as well as in many Windows applications that I wrote.
Jon's sample code shows the typical "state-switcher", like this:
To select a specific state, the caller, or a routine inside the state machine would have to assign a number from 0 up to the highest allowed state (2 in the example above) to the State variable before calling or re-entering the machine, e.g.:
Another version of a "state-switcher" may look like this:
Here, the address of the code segment to be executed must be assigned to the StateAddr variable, like this:
Both methods have thiur pro and cons. The first version makes it easy to sequentially switch from one state to the next by simply inrementing the State variable, where the second version is more self-documenting and shorter.
Have fun with FSMs!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G