1.50 1.51 1.51.01 1.51.02 ____________________________________________________________________________________________ What's New In SX/B 1.50 6/09/2006 Additions: WORD Variables Port variables: RBC, RCD, RDE __WPARAM12, __WPARAM23, __WPARAM34, __WREMAINDER WDATA ' word data always uses 2 bytes for each value FUNC returnbytes, min parameters[, max parameters] SHIFTIN & SHIFTOUT SpeedMult parameter COUNT command - Must stay in each state at least 40 clocks CMOS, TTL, SCHMITT, PULLUP commands for SX48 COMPARE ' SX48 works like BS2px command TIMER1 & TIMER2 commands ' For SX48 ONLY CLEAR, PWM, PRESCALE, TIMER, EXTERNAL, CAPTURE, R1, R2 Removed commands CLEART1, CLEART2 ON var GOTO label0, label1 ON var GOSUB label0, label1 ON var = x,y,z GOTO labelx, labely, labelz ON var = x,y,z GOSUB labelx, labely, labelx ELSEIF ' Makes writing CASE type if structures easier only need one ENDIF Enhancements: WATCH ' Automatically adds parameters only need "WATCH bytevar" FREQ clockSpeed[, timingSpeed] DATA ' allows values > 255 (stored as 2 bytes) var1, var2, var3 VAR Byte INTERRUPT rate ' rate = times/second to call interrupt Automatically sets OPTION and RETURNINT value wordVar = bytevar,bytevar cnt = T1CPL,T1CPH Allow "_" in all number formats Allow "-" & "~" as subroutine parameter prefixes __PARAMCNT is now a proper variable array(2) The following are allowed: array(2) = wordconst array(2) = array(2) array(2) = wordvar wordvar = array(2) ____________________________________________________________________________________________ What's New In SX/B 1.51 7/24/2006 ------------------------------------------------------------------------------- New Definition PIN [INPUT OUTPUT PULLUP NOPULLUP CMOS TTL SCHMITT NOSCHMITT INTR_RISE INTR_FALL] Defines a hardware pin and sets options for the pin. PIN is preferred over using VAR to define pins. PIN also supports whole byte and the pseudo-word ports. OUTPUT - Sets up the pin as an output INPUT - Sets up the pin as an input (default) PULLUP/NOPULLUP - Enable/disables ~20K pullup resistors for the pin (NOPULLUP is default) CMOS/TLL - Sets the pin voltage toggle threshold to Vdd/2 or 1.4V. (1.4V is default) SCHMITT/NOSCHMITT - Enables/disable schmitt trigger for the pin INTR_RISE/INTR_FALL - Enables pin interrupt for rising/falling edge (port B only) Examples: LED PIN RC.0 OUTPUT Switch PIN RC.1 INPUT CMOS ISwitch PIN RB.0 INPUT PULLUP INTR_FALL LEDS PIN RC OUTPUT ' Sets all RC bits to output ------------------------------------------------------------------------------- Conditional Compiling: '{$DEFINE name} '{$UNDEFINE name} '{$IFDEF name} '{$IFNDEF name} '{$ELSE} '{$ENDIF} Conditional compiling allows you have different versions or options in one SX/B program. For example lets say you have a program and sometimes you want to use RB for LED outputs and sometimes you want to use RC. '{$DEFINE USE_RB} ' Remove this line to use RC '{$IFDEF USE_RB} LEDS PIN RB '{$ELSE} LEDS PIN RC '{$ENDIF} ------------------------------------------------------------------------------- New commands: NOP Simply inserts a NOP [ Wow Terry that was a tough one ;) ] ANALOGIN InPin, OutPin, Value[, Prime] Reads an analog input voltage using the continuous calibration method All you need is 2 10K resistors and a 0.01uF capacitor(for 4MHz) or 0.001(for 50MHz) You can experiment with different resistor and/or capacitor values. Don't use resistor values below 220 ohms to protect the SX output pin. The variable Value will get set to the analog voltage at the input with 255 = Supply voltage. So if you get a reading of 127 and the supply voltage is 5 volts, then the input voltage is about 2.5 volts. Note that the input pin needs to be set to CMOS input threshold. By default the sx sets all pins to TTL threshold. The TTL theshold is 1.4Volts. That will make the full scale reading of 255 = 2.8 volts regardless of the supply voltage. The method needs to "prime" the capacitor to get a stable reading. By default the prime value is 1. If you get unstable readings either use a smaller cap value or increase the prime value. Prime must be a constant from 0 to 255. However larger prime values will increase the time it takes to get a reading. The time required to get a reading is 3825*(1+Prime)/Frequency. So with the default prime value of 1, if the clock is 4MHz it will take 3825*2/4000000 seconds or about 1.91 milliseconds to get a reading. For faster clocks either use a smaller cap value or a larger prime value. Note that this circuit has a fairly low input impedence. If you use a pot or resistor divider to create the analog voltage the ANALOGIN command may not reach the limits (0 or 255). A simple test using the 10K pots on the PDB yielded values from 0 to 241. The following is an example program: ------------------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX FREQ 4_000_000 InPin PIN RA.0 INPUT CMOS OutPin PIN RA.1 OUTPUT ' Analog Voltage >---/\/\/\-------+----+------------ SX Read Pin (RA.0) ' 10K | | ' ----- +--/\/\/\---- SX Write Pin (RA.1) ' ----- 10K ' 0.01uF / \ ' | ' | ' GND a VAR Byte PROGRAM Start NOSTARTUP Start: ANALOGIN InPin, OutPin, a, 2 WATCH a BREAK GOTO Start END ------------------------------------------------------------------------------- Fixes: "IF a1(1).7 = 0 THEN" caused an assembly error "a1(1).7 = ~a1(1).7" caused an assembly error "SHIFTOUT MSBFIRST \9..\16" bits not rotated correctly Incorrect error message when a duplicate variable name is used "ON GOTO | GOSUB" "GOTO" and "GOSUB" had to be uppercase "ON GOSUB" error when using defined subroutines ____________________________________________________________________________________________ What's New In SX/B 1.51.01 ------------------------------------------------------------------------------- New Command: READINC Exactly the same syntax as READ, but also automatically increments the offset variable to point to the next item in the DATA list. ------------------------------------------------------------------------------- Fixes: I2CSEND & I2CRECV didn't work on the SX48/SX52 WATCH array If array name is given, watches the array as a string. If an individual element is given, watch it as a byte. wordVar = ~bit Was generating code as if it was wordVar = -bit Conditional Compiling was including the '}' and anything after as part of the name ANALOGIN many jump didn't have '@' prefix Optimized, now cycle time is 11 cycles * 255 = 1.4mS per reading @ 4MHz FOR byteVar = 10 TO 0 STEP -1 Never did loop with byteVar = 0 (stopped at 1) ____________________________________________________________________________________________ What's New In SX/B 1.51.02 ------------------------------------------------------------------------------- New Commands: ------------------------------------------------------------------------------- Changes: Allow 5 parameter bytes ONLY IF the sub/func does not have a variable number of parameters. Ex: MySub SUB 5 ' This is legal Ex: MySub SUB 2,5 ' THIS IS NOT LEGAL Also FUNC can return upto 5 bytes ------------------------------------------------------------------------------- Fixes: RDE_LSB was set to $09 instead of $08 IF arrayelement.bit = arrayelement.bit THEN HIGH & LOW set latch before making pin an output What's New In SX/B 1.50 6/09/2006 Additions: WORD Variables Port variables: RBC, RCD, RDE __WPARAM12, __WPARAM23, __WPARAM34, __WREMAINDER WDATA ' word data always uses 2 bytes for each value FUNC returnbytes, min parameters[, max parameters] SHIFTIN & SHIFTOUT SpeedMult parameter COUNT command - Must stay in each state at least 40 clocks CMOS, TTL, SCHMITT, PULLUP commands for SX48 COMPARE ' SX48 works like BS2px command TIMER1 & TIMER2 commands ' For SX48 ONLY CLEAR, PWM, PRESCALE, TIMER, EXTERNAL, CAPTURE, R1, R2 Removed commands CLEART1, CLEART2 ON var GOTO label0, label1 ON var GOSUB label0, label1 ON var = x,y,z GOTO labelx, labely, labelz ON var = x,y,z GOSUB labelx, labely, labelx ELSEIF ' Makes writing CASE type if structures easier only need one ENDIF Enhancements: WATCH ' Automatically adds parameters only need "WATCH bytevar" FREQ clockSpeed[, timingSpeed] DATA ' allows values > 255 (stored as 2 bytes) var1, var2, var3 VAR Byte INTERRUPT rate ' rate = times/second to call interrupt Automatically sets OPTION and RETURNINT value wordVar = bytevar,bytevar cnt = T1CPL,T1CPH Allow "_" in all number formats Allow "-" & "~" as subroutine parameter prefixes __PARAMCNT is now a proper variable array(2) The following are allowed: array(2) = wordconst array(2) = array(2) array(2) = wordvar wordvar = array(2) What's New In SX/B 1.51.02 ------------------------------------------------------------------------------- New Commands: ------------------------------------------------------------------------------- Changes: Allow 5 parameter bytes ONLY IF the sub/func does not have a variable number of parameters. Ex: MySub SUB 5 ' This is legal Ex: MySub SUB 2,5 ' THIS IS NOT LEGAL Also FUNC can return upto 5 bytes ------------------------------------------------------------------------------- Fixes: RDE_LSB was set to $09 instead of $08 IF arrayelement.bit = arrayelement.bit THEN HIGH & LOW set latch before making pin an output