Shop OBEX P1 Docs P2 Docs Learn Events
SX Application Notes to be Improved - Input Needed — Parallax Forums

SX Application Notes to be Improved - Input Needed

Ken GraceyKen Gracey Posts: 7,401
edited 2004-11-27 07:00 in General Discussion
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:
  1. Essential VP’s (Timer, UART, PFM, PWM, Keyboard, Stepper, I2C Master, SPI Master, ADC)
  2. Application Note support for the above.
  3. VP Combinations including the above VP’s (UART + PFM, UART + PFM + Timer, UART + PWM, UART + PWM + Timer, plus others to be defined).
  4. Other VP’s (I2C Slave, dual I2C Multi-Master, dual UART, 8 UART, FSK, ISA)
  5. Application Note support for above.
  6. VP Combinations including the above VP’s (I2C Multi-Master + UART + Timer, I2C Multi-Master + Dual UART + Timer, plus others to be defined).
  7. Misc. Application Notes (EMI, SX28-52 Conversion, Arithmetic, etc.)
  8. Other useful applications
  9. VP Methodology
  10. 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 NewtonJames Newton Posts: 329
    edited 2004-10-26 00:28
    I'd like to see more flexability introduced into the code through the application of macros and defines. A lot of the timing stuff can be setup to automatically adjust to the frequency the chip will be running at by doing a few conditional compilations and some calculations.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ---
    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!



  • StephenStephen Posts: 53
    edited 2004-10-26 02:47
    That's a good idea... Some standard set of macros and defines applied to all would be best. Some pieces do require a deviation though, which would need to be documented appropriately. Do you have some examples that you prefer?
  • PJMontyPJMonty Posts: 983
    edited 2004-10-26 07:43
    I would like to suggest that a feature I added to SASM (in a version that has not yet been publicly released) should also be considered in any code given as examples. I modified SASM so that the "ERROR" function of SASM can be used to create more useful custom assembly messages by letting it display variables and constants.

    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


    ; NOTE! All UART timings assume a 1:1 RTCC
    ; Un-comment the desired baud rate for the UART
    ;BAUD EQU 9600
    BAUD EQU 19200
    ;BAUD EQU 38400
    
    ; 9600, 19200, and 38400 all use the same interrupt period
    int_period equ 163
    
    if BAUD = 9600
    ; *** 9600 baud
    baud_bit = 5
    start_delay = 32+16+1
    endif ; BAUD_9600
    
    if BAUD = 19200
    ; *** 19200 baud
    baud_bit = 4
    start_delay = 16+8+1
    endif ; BAUD_19200
    
    if BAUD = 38400
    ; *** 38400 baud
    baud_bit = 3
    start_delay = 8+4+1
    endif ; BAUD_38400
    
        ERROR p2w '----------------- Current Baud: ' BAUD ' -----------------'
    
    

    Post Edited (PJMonty) : 10/26/2004 7:47:19 AM GMT
  • James NewtonJames Newton Posts: 329
    edited 2004-10-26 17:34
    My standard template is at
    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!



  • Michael ChadwickMichael Chadwick Posts: 80
    edited 2004-10-26 19:30
    That 'hidden' feature of SASM would have saved me some time and trouble.· I use the ?(expression) feature of SASM macro processing to display things like how much room I have left in the first half of a page.· But I kind of had to beat it into submission before I got it to work the way I wanted it to.

    [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]
  • PJMontyPJMonty Posts: 983
    edited 2004-10-26 19:46
    Michael,

    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
  • James NewtonJames Newton Posts: 329
    edited 2004-10-26 22:56
    So Michael, the ?(exp) evaluates the expression before passing the result to the macro?

    - 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!



  • Michael ChadwickMichael Chadwick Posts: 80
    edited 2004-10-28 00:48
    Yes, the ?? is the token pasting operator, that pastes two tokens together into one. The leading $ make SASM interpret the value as hexadecimal. Only needed because I like to work in hex. [noparse]:)[/noparse]
  • Michael ChadwickMichael Chadwick Posts: 80
    edited 2004-11-27 07:00
    Hi All,

    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
Sign In or Register to comment.