SX Application Notes to be Improved - Input Needed
Ken Gracey
Posts: 7,401
Dear SXers,
The current Ubicom SX application notes we provide for download are quite dated. Sometimes parts are not available or the code does not assemble, or they need explanatory improvement.
Parallax is preparing to update these notes. We are doing so with Ubicom approval since they prepared many of the originals.·The work will be done by·Stephen Holland, a former Ubicom employee who wrote many of the notes. Our first order of operation is to put these applications in order of priority. At the moment, we have established our priorities like this:
Code would be done in SASM and wth one compiler, which we will select next week. We welcome all the input you can provide so we do what you would like us to do.
Ken Gracey
Parallax, Inc.
The current Ubicom SX application notes we provide for download are quite dated. Sometimes parts are not available or the code does not assemble, or they need explanatory improvement.
Parallax is preparing to update these notes. We are doing so with Ubicom approval since they prepared many of the originals.·The work will be done by·Stephen Holland, a former Ubicom employee who wrote many of the notes. Our first order of operation is to put these applications in order of priority. At the moment, we have established our priorities like this:
- Essential VP’s (Timer, UART, PFM, PWM, Keyboard, Stepper, I2C Master, SPI Master, ADC)
- Application Note support for the above.
- VP Combinations including the above VP’s (UART + PFM, UART + PFM + Timer, UART + PWM, UART + PWM + Timer, plus others to be defined).
- Other VP’s (I2C Slave, dual I2C Multi-Master, dual UART, 8 UART, FSK, ISA)
- Application Note support for above.
- VP Combinations including the above VP’s (I2C Multi-Master + UART + Timer, I2C Multi-Master + Dual UART + Timer, plus others to be defined).
- Misc. Application Notes (EMI, SX28-52 Conversion, Arithmetic, etc.)
- Other useful applications
- VP Methodology
- SX User’s Manual or Parallax SX-Key Manual additions
Code would be done in SASM and wth one compiler, which we will select next week. We welcome all the input you can provide so we do what you would like us to do.
Ken Gracey
Parallax, Inc.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
James Newton, Host of SXList.com
james@sxlist.com 1-619-652-0593 fax:1-208-279-8767
SX FAQ / Code / Tutorials / Documentation:
http://www.sxlist.com Pick faster!
For example, in the code snippet below, you can set the buad rate by un-commenting one of the available rates. However, I always found it annoying to wonder if I set the baud rate correctly for a given project, and thus having to look through the code. The main change I made to SASM was to allow "ERROR" messages take a variable or constant as a parameter.
"ERROR p2w" tells SASM to generate a warning on pass 2, and the constant "BAUD" is evaluated and the value displayed when the message is output on pass 2. Thus, when you assemble this code, you get a nice message like:
c:\Path to file\file.src(189) Line 224, Warning 75, Pass 2 "
Current Baud: 19200
"
I have also used this for situations such as code where I need to hardcode a network node address in a project. It's nice to always get a sanity check at assembly time and be able to see what address I gave the node without hunting for it in the source.
One caveat is that the the "ERROR" function can't evaluate expressions (such as "BAUD * 2"). However, this is easily overcome by putting the expression in a new constant or variable (such as "NEW_BAUD equ BAUD * 2") and then just using the pre-evaluated variable or contant in the message. Bear in mind that it's HIGHLY recommended to always use pass two since you know that all variables and constants will be fully evaluated by then.
Thanks, PeterM
Post Edited (PJMonty) : 10/26/2004 7:47:19 AM GMT
http://www.sxlist.com/techref/ubicom/sasm.htm
It probably needs some tweeking, and you may not wish to use all the features in the include files. But they do remove most of the problems people have with coding for the SX. E.g. no more paging issues, subroutines can be anywhere, delays adjust to clock speed automatically, conditionals are easy to evaluate, etc...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
James Newton, Host of SXList.com
james@sxlist.com 1-619-652-0593 fax:1-208-279-8767
SX FAQ / Code / Tutorials / Documentation:
http://www.sxlist.com Pick faster!
[noparse][[/noparse]code]
;
; General purpose macros to allow warnings if a page boundary is exceeded
; and to allow the display of variables and calculations at assembly time.
;
; Only two are used directly, the others support the evaluation of the
; variables and expressions.
;===============================================================================
; Requires the use of SASM or it won't work.
;*******************************************************************************
; Use as follows:
;·org ISR_BANK
; ..........................
; code etc goes here, the ISR, subroutines etc.
; ..........................
; at the end of the code that must be in the lower half of the bank
; do this:
; checksub·ISR_BANK
; it will generate an assembler user warning that the subroutines went past
; the first half of the page by how ever many bytes they did, displayed in hex
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;
; may be used with {Text to be displayed goes in here} to generate a warning
; from a text string
warning··MACRO·text
··ERROR P1W ?text
··ENDM
;
; Basic text display macro that allows multiple arguments.· This is handy
; because SASM macros allow evaluation of an argument as an expression
; by enclosing the expression thus: ?(expression) on the macro invocation
; line.· So we can calculate things and display them as appropriate.
distext··MACRO
··if(\0>=10D)
··warning {\1??\2??\3??\4??\5??\6??\7??\8??\9??\10}
··endif
··if(\0=9)
··warning {\1??\2??\3??\4??\5??\6??\7??\8??\9}
··endif
··if(\0=8)
··warning {\1??\2??\3??\4??\5??\6??\7??\8}
··endif
··if(\0=7)
··warning {\1??\2??\3??\4??\5??\6??\7}
··endif
··if(\0=6)
··warning {\1??\2??\3??\4??\5??\6}
··endif
··if(\0=5)
··warning {\1??\2??\3??\4??\5}
··endif
··if(\0=4)
··warning {\1??\2??\3??\4}
··endif
··if(\0=3)
··warning {\1??\2??\3}
··endif
··if(\0=2)
··warning {\1??\2}
··endif
··if(\0=1)
··warning {\1}
··endif
··ENDM
;
;example use of distext to display mixed text and values.
;distext {Current Program Version:SPEM }, ?VERSION_MAJOR, {.}, ?VERSION_MINOR, {.}, ?REVISION, {.}, ?PLATFORM
;
;
; only used to display the Subroutine warning message with variables
; substituted into the message for the specific program bank
difference·MACRO·pagestart offset
··warning·{pagestart??: Subroutines over by 0x??offset??.}
··ENDM
;
; checks if loc is past pagestart + $ff and issues warning if it is
pagetest·MACRO·loc, pagestart
··IF($??loc > pagestart+$100)
;··make error because the page went too long for subroutines!
··distext·{pagestart??: Subroutines over by 0x}, ?($??loc-pagestart-$100), {.}
;··difference pagestart, ?($??loc-pagestart-$100)
··else
··distext pagestart, {is OK.}
··ENDIF
··ENDM
;
; Simplifies the use of the rest to give a nicely formated and informative
; warning message to indicate we are past the first half of a page and
; by how much so we can work out how to trim things back
checksub·MACRO·startofpage
··RADIX·HEX
··pagetest ?($), startofpage
··RADIX·D
··ENDM
;
; Sample macro usage that displays the amount of space left in the first half
; of the current page if any and displays how much over if over.
checkpage·MACRO
··RADIX H
··distext {CHECKPAGE: program counter is 0x}, ?($), {.}
··if($&$1ff < $ff)
···distext 0x,?($100-($&$ff)),{ Bytes left in the first half of the page.}
··else
···distext 0x,?(($&$1ff)-$ff),{ Bytes beyond the first half of the page.}
··endif
··RADIX D
··ENDM
[noparse][[/noparse]/code]
I'm always impressed what someone with a macro language and the determination to accomplish something can do. Still, hang in there as a new version of the IDE will be released in a reasonable time frame. We're still just beta testing things like this so hopefully it's a "clean" release.
Thanks, PeterM
- Does that imply that the result must be a number?
And the exp??exp form "concatinates" two values into a string?
- I'm confused by "$??loc " in the pagetest macro. Is that appending the literal symbole ($) to an address?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
James Newton, Host of SXList.com
james@sxlist.com 1-619-652-0593 fax:1-208-279-8767
SX FAQ / Code / Tutorials / Documentation:
http://www.sxlist.com Pick faster!
I just realized that switching the error line in the warning macro I posted in this thread from 'ERROR P1W' to 'ERROR P2W' to get around a problem with pass 1 warnings in the latest version of SASM, broke the display of values in hexadecimal. For whatever reason, using the ERROR directive in that way as a pass two warning, it seems to ignore the RADIX directive.
MRC