SX/B Directives |
DEVICE (Required) |
DEVICE [SX18 | SX20 | SX28 | SX48 | SX52] {, ...}
The DEVICE directive specifies the device type (e.g, SX18, SX28), oscillator type, and other SX fuse settings.
DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
Consult the SX-Key Development System Manual for a complete list of SX DEVICE options.
IRC_CAL |
IRC_CAL [IRC_SLOW | IRC_4MHZ | IRC_FAST]
The IRC_CAL directive specifies the calibration value for the internal RC oscillator.
When the options IRC_SLOW or IRC_FAST are specified, the IRCTRIM bits in the FUSEX device configuration register are programmed to the minimum or maximum frequency value. When the option IRC_4MHZ is specified, the SX-Key software performs a calibration procedure whenever a program is downloaded to the SX chip and adjusts the IRCTRIM bits so that the internally generated clock frequency comes close as possible to 4 MHz.
IRC_CAL IRC_4MHZ ' calibrate internal RC clock
When not specified, the IRC_CAL setting is defaulted to IRC_SLOW.
FREQ (Required) |
FREQ Hertz{, EffectiveHz}
The FREQ (frequency) directive is used to set the frequency (in Hertz) of the SX-Key's internal programmable oscillator to be used during debugging. FREQ is also used by the SX/B compiler for calculating delays in timing-sensitive instructions (PAUSE, SERIN, SEROUT, etc.), so connecting a clock source that differs from the compiled FREQ setting will affect stand-alone operation.
FREQ 4_000_000
Note that frequency can be any number from 31250 to 110000000, but debugging via the SX-Key only works with frequencies between 400000 and 110000000. Additionally, underscore characters can be used to help make the number more readable, as in 50_000_000, which is 50 MHz.
The optional parameter, EffectiveHz is used to calculate the timing for SX/B instructions. If the program uses an interrupt to perform background functions this value can be used to compensate for the time spent in the interrupt routine. For example, if the interrupt is 100 cycles and is called every 1000 cycles, you would adjust the frequency by 10% by using:
FREQ 4_000_000, 3_600_000
ID |
ID ID_String
The ID (identification) directive is used to write up to eight bytes of text into the ID word of the SX chip. This is used to record a version number or other unique identification for the code. This ID word can be read out of the SX chip at any time, regardless of the code protect setting. The line below will write GPXv2.1 into the ID word:
ID 'GPXv2.1'
WATCH |
WATCH Variable{.Bit}, Count, Format
The WATCH directive allows the definition of format for viewing and modifying variables at runtime during debug mode. The variable's name, number of bits or bytes to view, and display format may be specified.
WATCH hertz, 16, UDEC WATCH timer, 8, UDEC WATCH flags.0, 1, UBIN
The table below lists the available format settings for the WATCH directive.
Format | Operation |
UDEC | Displays value in unsigned decimal format |
SDEC | Displays value in signed decimal format |
UHEX | Displays value in unsigned hexadecimal format |
SHEX | Displays value in signed hexadecimal format |
UBIN | Displays value in unsigned binary format |
SBIN | Displays value in signed binary format |
FSTR | Displays value in fixed-length string format |
ZSTR | Displays value in zero-terminated string format |
Consult the SX-Key Development System Manual for additional information about the WATCH directive.
Note: As of SX/B version 1.5, WATCH may be used in a simplified format:
WATCH anyVariable
The compiler will insert the correct number of bits and specify UDEC format.
LOAD |
LOAD "FileName.SXB"
The LOAD directive is used to insert an SX/B source code file at the current location.
LOAD "LCD.SXB"
INCLUDE |
INCLUDE "FileName"
The INCLUDE directive is used to insert an SX assembly code file at the current location.
INCLUDE "I2C.SRC"
PROGRAM (Required) |
PROGRAM Label {NOSTARTUP}
The PROGRAM directive sets the execution start point (at a label) for the SX/B program. Note that the PROGRAM directive must appear after the (optional) INTERRUPT hander, and in the first code page ($000 - $199).
When the NOSTARTUP option is used the SX/B compiler will not insert the normal start-up code that pre-initializes all RAM addresses to zero; in this case the programmer is responsible for appropriate initialization, except the FSR which is cleared (see BANK, below).
PROGRAM Start Start: TRIS_B = %00000000 Main: INC RB PAUSE 1000 GOTO Main
BANK |
BANK {DefaultBank} {NOCODE}
The BANK directive loads the BANK (FSR) variable with DefaultBank. The value will also be reloaded after any instruction that modifies BANK (FSR). DefaultBank may be a constant or a byte variable that is in the global RAM area (location <$10). If DefaultBank is the first variable declared, it will be in the global area.
If the NOCODE option is specified the BANK (FSR) is not changed immediately. This is useful if you know that the BANK (FSR) has ready been set, so there is no need to set it again. Since BANK is a compiler directive it's affect is strictly top-down, that is, its affect does not follow program flow if the program branches to a different section of code.
If BANK is used with no parameters, it will set the BANK (FSR) to the DefaultBank. This is useful in assembly routines, otherwise you would have to store the current FSR before using it.
BREAK |
BREAK
The BREAK directive inserts a breakpoint into the assembly code which can useful during program debugging.
Start: TRIS_B = %00000000 BREAK Main: INC RB GOTO Main
Note that only one BREAK directive may be used in an SX/B program. To create the effect of multiple breakpoints, the programmer may insert the BREAK directive into a subroutine that can be called from any point in the program.
ADDRESS (Obsolete) |
ADDRESS PageAddr
The ADDRESS directive sets the starting location for the instructions that follow.
Page_1: ADDRESS $200
Note that as of version 1.2, it is no longer necessary for the programmer to manually set code page addresses.