First Steps
After getting to feel fairly comfortable with the BS2 and PBasic I want to spend some time on the SX/28. I don't have any particular project in mind but my question is what is the general opinion on basic v assembly, do you think learning assembly has benefits worth the time it takes to learn. Is assembly as good as basic, better than basic or a lot better than basic? All I have done with the SX so far is make a LED blink with the LED.src code provided, that wasn't too difficult [noparse]:o[/noparse]). I think I know which way to go but welcome any comments/input on language preference and anything that gives me·added insight on what the SX is capable of.
thanks in advance
Jeff T.
thanks in advance
Jeff T.
Comments
Personally I have never owned a Basic Stamp of any sort, so I have no idea as to its ease of use. I happen to get involved with the SX in assembler, and that's all I really know. Although I had a go at SX/B, but found it somewhat limiting, and quickly gravitated back to my comfort zone - assembler.
I'm interested in trying out the C language and hope that it will be available in stable form soon.
I also hope that SX/B can be enhanced to make it multi tasking, thereby removing its biggest obstacle..... it could become a real rocket!
I believe that assembler is only slightly more difficult than the other approaches, but for me at least, it takes much longer to write code. Once that is done however, it's performance will outshine anything else...... by a LONG shot.
So it all depends on your particular bent, higher level languages for convenience, or assembler for performance.
My view.
Cheers,
Peter (pjv)
Remember, SX/B compiles to straight assembly -- now, it will never be quite as fast as properly designed, hand-coded Assembly, but it will absolutely run circles around the same program running on a BASIC Stamp.
Peter, you say C in stable form does that mean there is C in unstable form right now? I used to do a small amount of C programming as a hobby and would be interested if it were available for the SX.
thanks
Jeff T.
I understand that Parallax has a "C" compiler deal in the works with CCS for some time now, and hopefully that will be out of Beta testing soon.
It is of course not up to me to make predictions.... Parallax will surely do that in due course.
Cheers,
Peter (pjv)
··········· Guess who?· I have my· sx chip now and I am also interested in assembly language. Drop me an e-mail if you read this today.
··········· rickymcc@netzero.net.
·············································· Ricky
to "unsoundcode":
well, even the non-blazing speed is too fast to comprehend now-a-days --- let me add "pin-point accuracy" to the phenomenon called assembly language --- what you write is what the chip does ! ! ! --- nothing less, nothing extra.
you say that you have made an LED blink - well if you can see the blinks, then you must have written code to make a "delay" of some sort - "wasted time" making the chip count to 2,000 or 20,004 --- and now instead of lighting a light, you might trigger another chip to sequence current to a stepper-motor, or to count the vibrations in your TV-remote's infrared signals...
it's "pure" - this assembly language - and each small part is fairly simple, too. Your own little library of more complicated tasks will build rather quickly - and you will find satisfaction in "complete control" - that you know the purpose of every byte in the program. If your chip is mis-behaving --- you told it to do that - (and therefore you can fix it, too).
Basic is too vauge -- maybe I can use my old basic stamp as some sort of memory device for a data-logger --- I "dropped" it after only one program when I then discovered the SX chips... and good ol' Assembly Language.
tommy
The "Exploring the SX Microcontroller with Assembly and BASIC" is very old. That book was written for the first or second release of SX/B and won't give you the right introduction. Instead, use the SX/B Help File as your guide, as well as any SX/B examples you draw from the Parallax web site.
In short time, Jon Williams' book "Practical SX/B" will be available. John Kauffman's SX/B book is also underway, each with a different approach. You'll learn about those resources on this forum first, of course.
Ken Gracey
Parallax, Inc.
Jeff,
Tough questions here.
Yes, learning assembly will definitely help you in the microcontroller world. These type of projects are hardware related and can require tight timings, especially when communicating to outside chips and devices. Because you know each instruction takes a certain number of cycles(usually 1 instruction = 1 cycle = 20ns at 50mhz) it's easy to tell exactly when something is going to happen. Assembly is about as close to the hardware as you can get and so it is a low-level language. Low-level languages give you the power to do whatever you want, but comes at a price of complexity, and things that you might take for granted in a higher-level language simply aren't there in assembly. Assembly instructions are usually the most basic, the most atomic operations you can perform.
Basic on the SX I've found to be really easy. Quick to pickup. It's not a "full-fledged" version of basic, unlike what you might have played with on a PC. There are some commands that have limited flexibility and options, but newer additions like 16-bit variables are nice. It has some nice features like I2C support, one wire stuff, a UART that runs at a respectable speed(although I'd love to see this work even faster) As far as "rapid application development", basic is great for throwing together a working program quickly.
For my purposes (hobby projects etc), I use a mixture of assembly and basic on the SX. For anything with critical timing, I use assembly. In my current project, I have my ISR written in assembly, because it's firing pretty frequently, and I wanted to get in and get out. For my memory communication, I'm doing everything in assembly. I *was* using assembly for a bit-banging UART, but found that I had a minor timing glitch (related to MOVB taking a different number of cycles based on contents of the source bit), and so the (although maybe temporary) fix was actually to go to known-good working code, the basic UART.
Answer? Use the right tool for the job.
HTH,
Keith
Tommy, I made that led blink with copied code, but·I do·fully understand it now. Like you say I understand every byte, Im not going to give up it's just going to take a long time.
Ken, Im hungry for good books and have already been recommended to look at some of Guenther's works.
Keith, I'm purposely staying away from the SX basic for now to avoid slipping into the easy way out, once I feel I am somewhere near competent I will then look at the basic, right now I will concentrate on asm. ISR's and Uart's I see are important, but so difficult to understand.
Thanks again for the support
Jeff T.