sx28 to sx48 code compatibility
I've worked through most of the Stamps in class texts. I would like to start working on some useful projects now, but can't afford the per module cost of the stamps. I also am interested in not just learning enough to complete a project but learning all I can, for the sake of learning. ( one of the projects I want to do is put a controller on my homemade coffee-roaster but I can't see spending $70 on a stamp, when the sx proto board is only $10)
Anyway, I started reading some of the SX documentation and my question is:
is there much difference between the sx28DIP and the 48 code? Today I read about the M register and started seeing things like "ok you can write '$c' to the register, unless it's a 48, then you write a $1c' (or something to that effect). So if I used say an SX Tech kit for learning, is it a major pain to "port" the code over to the 48 where it would live? or is it better to just do all of the work on the proto board and forget about the sx28?
am I making sense in this? I just finally got my kids to bed after an awful day at work (for me, not the kids) and I'm having a serious case of cranial flatulence
thanks!
paul...
Anyway, I started reading some of the SX documentation and my question is:
is there much difference between the sx28DIP and the 48 code? Today I read about the M register and started seeing things like "ok you can write '$c' to the register, unless it's a 48, then you write a $1c' (or something to that effect). So if I used say an SX Tech kit for learning, is it a major pain to "port" the code over to the 48 where it would live? or is it better to just do all of the work on the proto board and forget about the sx28?
am I making sense in this? I just finally got my kids to bed after an awful day at work (for me, not the kids) and I'm having a serious case of cranial flatulence
thanks!
paul...
Comments
Are you going to be programming in assembly or SX/B?
SX/B (Basic Compiler) is free and is/was intended to be an aid in learning assembly. If using SX/B all you have to worry about is getting the DEVICE and FREQ statements correct between the two chips and of course using the right ports, SX28 does not have a port D or E.
SX/B is a great tool, even Parallax uses it to create their ParallaxFX expansion products.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
"OEM NMEA GPS Module" Now available on ebay for only $17.49
http://www.allsurplus.net/Axiom/
Post Edited (Mike Cook) : 3/10/2006 1:42:55 AM GMT
mainly I will use the lang that allows me to do what I need to do.
I am not opposed to asm, I have somex86 and vax experience in asm.. so most of what I've seen in it makes sense
In SX/B, after you compile you can do a <CTRL-L> to look at the assembly code it generates for each statement. Download the SX-KEY IDE from Parallax, it includes SX/B, and take a look at the SX/B help file.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
"OEM NMEA GPS Module" Now available on ebay for only $17.49
http://www.allsurplus.net/Axiom/
I am trying to provide a brief summary for overview. You can make a check list of these 5 areas.
Introductory Info
The differences·all have some affect on your programing code. Begin by studying and programing the SX-28.
Guenther's book primarily focuses on it.
The way that RAM is laid out, there is a convienient algorhythm to initialize all the SX-28 RAM to zero; but it won't work on the SX-48. You have to use a 'brute force' method to do the same job. [noparse][[/noparse]A bit more code]
EEPROM pages are split in low and high. Subroutines should start in the Low portion as there is a 9th bit that the Call routine always reads as Zero [noparse][[/noparse]you have to Call, then Jump to get to the High part in a subroutine; then return from 'far']. So subroutines must begin in the low half of each of the 4 [noparse][[/noparse]on the Sx-28] or the 8 [noparse][[/noparse]on the Sx-48] pages.
The Checklist.
1. Ram - The SX-48 is double the SX-28. Both use $00 for 'global RAM
The Sx-28 uses every other bank $01, $03, $05; while the SX-48 uses All the banks $01,$02,$03....
2. EEPROM - The SX-48 has double the SX -28.
The Sx-28 has 4 pages; the SX-48 has 8 pages
3. Mode - The SX-48 has more Modes due to additional timers so the code is not quite the same
4. Ports - The Additional D and E ports use space that in the SX-28 may be used for global RAM in the SX-28
5. Additional timers - Compare and capture features in hardware may eliminate the need for some software timers.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Post Edited (Kramer) : 3/10/2006 4:53:43 AM GMT
Kramer: 'zactly what I was looking for. so there are a few small gotchas it seems, but excepting those, code written, tested on the 28 should port to the 48 without too much fighting/work.
I will probably order the SX tech kit today.
paul...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
For the SX28 the registers are write-only (you cannot read them back). On the SX48 you can read them back.
BUT the mode value to WRITE to a register on the SX28 will READ the register on the SX48.
For example MODE $0F on the sx28 will WRITE to the TRIS registers, but on the SX48 $0F will READ from the TRIS registers.
On the SX48 you must use $1F to WRITE to the TRIS registers.
So...
SX28 Code
MODE $0F
Must be translated into
SX48 Code:
MOV W,#$1F
MOV M,W
Now another side affect is that the code on the SX48 mangles the W register, where the code on the SX28 leaves it alone.
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
"Wise men know when they're right. The wisest also·know when they're wrong."
·
Make sure that you only invoke the _mode and _bank macros instead of directly placing mode or bank instructions in the code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
appealing.
Guenther: Wir (meine Familie und ich) sind gerade von Deutschland zurueckgekommen, Ich freue mich Ihr Buch zu lesen. Ich werd es heute noch bestellen.
University of pouring? Sounds like a training school for Oktoberfest
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
ha, ha, this is great!
Correctly translated, the sentence shoud read: "I have studied German (University of Giessen)". The city of Giessen is famous for its university - on the other hand, the German verb "giessen" means "poaring", so this is what the translating software messed up. A training school for Oktoberfest might be located in the southern area of Germany, like in Weihenstephan, where a famous University for brewing is located.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
Funny thing though, no one has written macros to go the other direction.
I just thought I would mention that the 2006 catalogue is advertising a SX28 protoboard similar to the SX48 protoboard. If you feel that would be easier, you might look for it.
My Development Package came with the SX28 DIP set up. If you get that, you may find it quite adequate. the SX28s are about $3, the protoboard will be about the same as the SX48. So I wonder if there will be a lot of takers. Very hard to predict.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Hmm - do you really mean macros to "downgrade" SX48/52 code to an SX20/28 ??? How could that fit into the SX2x smaller RAM/ROM?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
But, downsize ..... Yes.
Parallax in the past year sold a lot of SX-48 protoboards as it was newly introduced.
I suppose that someone with build all their prototypes on an SX-48 protoboard and get very comfortable with its version of code.
Then they may want to go into production with an SX-28 to save costs as they don't need all the ports or rom or ram or other Mode features.
At that point, they will find that that conditional compilation from Ubicom only provides for SX-28 code being shifted to SX-48.
Like I said, it is a funny thing, a bit of a strange idea -- but a real possiblity. I guess I think too much. But if you want to make a bet that someone in the next year or two will be posting this problem, I think I can easily win.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
When using an SX-48 protoboard having in mind to develop an application that will later run on an SX28, you can use the macros as shown. In addition, you should take care not to use the second half of the SX48 program memory, and not to use the additional RAM available in the "big brothers".
BTW: As far as I know, there will be an SX28 protoboard avilable soon, similar to the 48/52 types.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
also, please note that if you plug anything I type in German into a translator, be prepared, my German is nowhere near what it used to be. Not much call for German in the middle of the mid-west even with Daimler-Chrysler not far away.
naja, alea iacta est!
Did I get that right? Translator software is literal, it won't handle a lot of colorful expressions and idiom. Such things are too unpredictable.
Yes, the 28 protoboard is coming.
And like the SX-48 protoboard, it will easily allow you to crank the SX-28 up to its higher speeds [noparse][[/noparse]75Mhz or more]. I have been concerned that building a one or two layer board won't do much to keep down the EMI at that speed.
Actually, I learned a lot from making the little check list above.
Review and overview is really helpful and a great confidence builder.
I hope that Guenther will write an advanced SX programing guide for the SXes as he really knows his material and communicates well. I am particularlly interested in how to multiplex and combine VPs.
Just recently someone was asking about moving ADC data to RS-232 [noparse][[/noparse]for a modem] and I brought the question up of whether it wouldn't be possible to just go from the ADC to a VP Modem. Still you might want to keep the RS-232 output for installation and local observation.
As you can see, that is an ambitious, but useful project for remote data collection.
After you get the basics, one needs to learn to multiplex VPs.· You can begin to dream about new combinations without shopping for a chip with all the features already installed. [noparse][[/noparse]I don't think anyone has ever produced a hardware Modem feature.]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Post Edited (Kramer) : 3/13/2006 9:17:19 AM GMT
Naja, alea iacta est - est linguam Latinam - Gallia est omnis divisa in partes tres, unam inclunt Belgae, aliam Aquitani, tertiam qui linguam ipsum Celtae, linguam nostram Galli appellantur (at school, I once had to learn this text by heart, and now I seem to never forget it again)
Kramer, well, I'm thinking of some advanced programming guide for the SX, or - maybe - a Tips and Tricks kind of book - If I only had the time... BTW, in my existing book, you can also find some examples with more than one VP running at the same time, like an ADC and Timers in the Morse Code Keyer application, or a 7-segment driver and Timers in the clock examples but I agree, some more general information and more examples would be helpful.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
this is all still a little over my head.. altho I can see where I might need it.. (not the remote data part) as after I control the coffee roaster, I would consider building a controller for my beer brewing. Been done before by others, one can find all kinds of info on the net about it. and only a little more complex than my coffee roaster as it would need to handle 2 or 3 closed loop heating circuits.. and from what I can see/ascertain, still somewhat overkill for the sx48.. I would have lots of unused I/O pins. .but then again, at $10 I wouldn't care too much..
thanks to everyone for posting.
paul...
There is some weirdness with bank 0 ram on the sx48 that I don't quite understand yet, I just avoid using it. Also at first I was using the sx_key assembler but discovered that sasm is now recomended, this confused me since I am using the sx key product, do I have this right? Also I didn't see any documentation on the carryx directive which seems to cause add and sub to use the carry/borrow flag but is not the default, at least not in most of the sample programs I looked at, except in the math routines, took me a while to figure out why they weren't working.
Love the sx chips though, gives you way more control than with stamps, although coding is slower going at least until I get more proficient. I am building a device to profile racing canoes. I have accelerometer data being collected by one vp (paddler stroke rate & power) and two serial vps, one to collect positional data from a gps and one to send data to a data logging device (palm pilot) for storage, display and summary.
adrian.
This is because those two RAM addresses are taken over by the additional Ports D and E.
So you gain Two ports with 16 pins, but loose two bytes of RAM in Global RAM. Gain here and loose there.
Hopefully, you can just shift your RAM addresses upward and don't need those extra two bytes.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Ya and it does suck having only six bytes of global ram especially when you are moving data between vps and subroutines, I'm still getting used to that.
Adrian.
The bank0 of the SX48/52 is tricky. I have seen formal explanations of how to access bank0 but it seems sort of specialized compared to the use of the other banks, which you can access "normally". I still don't really get how to take advantage of it for common projects, and at the moment, I also have been just ignoring it.
I experimented a little with changing the carryx setting when I was working on some multibyte multiplication and division. Again, while the formal explanation seemed correct about what it does, in practice, it is a tricky little flag. Changing it caused little peculiarities throughout my entire program in all the places where my code depended on how the flags are used.
It seemed to me that some functions could benefit by changing its setting, but others would suffer. My advice would be to settle on one setting or the other and design all your code around which you chose from the start. My personal approach was to settle on the default setting and program accordingly.
David
Has that been done?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
One set is accessed by changing FSR and using IND, the other set by setting FSR to $00 and using MOV $10-$1F.
For example:
· MOV FSR,#$10
· MOV IND,#$12
· MOV FSR,#$00
· MOV $10,#$34
These do NOT access the same memory.
Another problem is the set that you must use MOV $10-$1F does NOT show on the debugger screen.
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
"Wise men know when they're right. The wisest also·know when they're wrong."
·
One set is accessed by changing FSR and using IND, the other set by setting FSR to $00 and using MOV $10-$1F.”
Bean,
I have the “SX-Key/Blitx Development System Manual”, and Guenther’s book, “Programming the SX Microcontroller”. Perhaps I missed it, but to the best of my knowledge, I have never read anything related to what you wrote above. Where do you find this information? I also just found out that I ought to use a 1F when setting the mode register on an SX52 rather than an 0F. I was using the 1F only because I am modifying an existing program, not because I read it anywhere. It seems that some of the information related specifically to the 48/52 is in the books, but scattered hither and yon. I wish it could be gathered together, and spelled out clearly somewhere. After reading some of the previous posts, it would seem that I am not the only one frustrated with this.
Here is a related question for you. . . looking at the Mode Register chart on page 173 of the System Manual, it looks to me that
$08 = $18
$09 = $19
$0a = $1a
$0b = $1b
Is this true? If not, in what situations is it not?
Anyway, for the most part, the information is clear and concise, but seems somewhat lacking regarding the SX48/52.
Bill Franke
One of the SX 2005 contest awards was for work on a RTO using undocumented registers.
Still, I find this a bit confounding.
When he says, 'there are basically two sets of memory locations from $10 to $1F,' I begin to envision of a shadow RAM of some sort.
AND, he says that it is only in the SX48 [noparse][[/noparse]not the SX28?].
Does this have to do with the needs of the ISR routines?
{As I recall, there seem to be a duplicate set of registers for the lower global registers and these are there to reinstate the system at the end of an ISR. Do you mean to say that this duplication extends to all the global registers?}
Can you refer to pages in Guenther's text which explain?
Can you refer to pages in PDFs that explain?
Is there a rational explanation for its existence?
{I begin to wonder if the shadow registers had to be extended upwards because there were more ports on the SX-48.}
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Yet the SX48 has 262 bytes of RAM. The other 16 locations are not accessible by using FSR (indirect addressing).
Look at the SX48 clear memory routines, you will see that there are 16 bytes that must be cleared using direct addressing.
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
"Wise men know when they're right. The wisest also·know when they're wrong."
·