In SX Microcontrollers, SX/B Compiler and SX-Key Tool, nige66 wrote: Using professional development board, with sx key,to program SX, program works well with SX key attached, when I try to run standalone, it doesn't seem to run. I had a break from this programming so I would imagine a fairly straight forward fix. Using Pulse gen on Development board for input frequency to count, displays freq on LCD thanks nige ' Reads a frequency and countspulses then converts to display on serial backlit LCD ' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX28, OSCXT2, TURBO, STACKX, OPTIONX FREQ 4_000_000 ID "SEROUT" ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- PotPin VAR RA.0 ' I/O pin for RCTIME Sout VAR RA.1 ' output to 2x16 freqin VAR RA.3 ' frequency input ' ------------------------------------------------------------------------- ' Constants ' ------------------------------------------------------------------------- Baud CON "N9600" LcdI CON $FE ' instruction LcdCls CON $01 ' clear the LCD LcdHome CON $02 ' move cursor home LcdCrsrL CON $10 ' move cursor left LcdCrsrR CON $14 ' move cursor right LcdDispL CON $18 ' shift chars left LcdDispR CON $1C ' shift chars right LcdDDRam CON $80 ' Display Data RAM control LcdCGRam CON $40 ' Character Generator RAM LcdLine1 CON $80 ' DDRAM address of line 1 LcdLine2 CON $C0 ' DDRAM address of line 2 duration CON 900 ' sample count duration Backlite CON $FD ' back lite command ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- analog VAR word ' anathou var word anahun var word anaten var word anaone var word anacalc var word char VAR Byte ' character to send idx VAR Byte ' loop counter lcd buffe idxs VAR Byte ' loop counter speed line1 VAR Byte(16) ' line 1 buffer line2 VAR Byte(16) ' line 2 buffer spd VAR Byte(4) ' speed array thou VAR spd(0) ' thou hund VAR spd(1) ' hund tens VAR spd(2) ' tens units VAR spd(3) ' units tmpB1 VAR byte ' subroutine work vars tmpB2 VAR Byte tmpW1 VAR Word ' ========================================================================= PROGRAM Start ' ========================================================================= ' ------------------------------------------------------------------------- ' Subroutine DECLARATIONS ' ------------------------------------------------------------------------- TX_BYTE SUB 1, 2 ' transmit a byte DELAY_US SUB 1, 2 ' delay in microseconds DELAY SUB 1, 2 ' delay in milliseconds UPDATE_L1 SUB 0 ' update line 1 of LCD UPDATE_L2 SUB 0 ' update line 2 of LCD UPDATE_LCD SUB 0 ' update both lines ' ------------------------------------------------------------------------- ' Program Code ' ------------------------------------------------------------------------- Start: DELAY 750 ' let LCD initialize TX_BYTE LcdI ' clear screen, home cursor TX_BYTE LcdCls pause 50 TX_BYTE LcdI ' clear screen, home cursor TX_BYTE Backlite ' back light on DELAY 1 put line1, "RPM: " ' initialize LCD buffer PUT line2, " " Main: count freqin,duration,analog ' read freq (10 us units) anathou = analog / 1000 ' freq in / 1000 if > 1000 then 1000's will be in anathou LSB anahun =__wremainder ' anahundred word contains remainder thou=anathou_lsb ' convert to single byte for use in TXBYTE anahun= anahun/100 ' anahund / 100 if > 100 then will be in anahun LSB anaten=__wremainder hund=anahun_lsb anaten = anaten/10 anaone=__wremainder tens=anaten_lsb units=anaone_lsb thou = thou + "0" ' convert 1000s to ASCII PUT line1(6), thou ' move to LCD buffer, in position 6 hund = hund + "0" ' convert 100s to ASCII PUT line1(7), hund ' move to LCD buffer in position 7 tens = tens + "0" ' convert 10s to ASCII PUT line1(8), tens ' move to LCD buffer units = units + "0" ' convert 1s to ASCII PUT line1(9), units ' move to LCD buffer UPDATE_L1 ' update LCD UPDATE_L2 GOTO Main ' do it over ' ------------------------------------------------------------------------- ' Subroutines Code ' ------------------------------------------------------------------------- ' Use: TX_BYTE theByte {, repeats } ' -- first parameter is byte to transmit ' -- second (optional) parameter is number of times to send TX_BYTE: tmpB1 = __PARAM1 ' char to send IF __PARAMCNT = 1 THEN ' if no repeats specified tmpB2 = 1 ' - set to 1 ELSE tmpB2 = __PARAM2 ' - save repeats ENDIF DO WHILE tmpB2 > 0 SEROUT Sout, Baud, tmpB1 ' send the character DEC tmpB2 LOOP RETURN ' ------------------------------------------------------------------------- ' Use: DELAY_US us ' -- 'us' is delay in microseconds, 1 - 65535 DELAY_US: IF __PARAMCNT = 1 THEN tmpW1 = __PARAM1 ' save byte value ELSE tmpW1 = __WPARAM12 ' save word value ENDIF PAUSEUS tmpW1 RETURN ' ------------------------------------------------------------------------- ' Use: DELAY ms ' -- 'ms' is delay in milliseconds, 1 - 65535 DELAY: IF __PARAMCNT = 1 THEN tmpW1 = __PARAM1 ' save byte value ELSE tmpW1 = __WPARAM12 ' save word value ENDIF PAUSE tmpW1 RETURN ' ------------------------------------------------------------------------- ' Transfers line 1 buffer to LCD ' -- makes no change in LCD screen position UPDATE_L1: TX_BYTE LcdI ' cursor to line 1, col 0 TX_BYTE LcdLine1 DELAY 1 FOR idx = 0 TO 15 TX_BYTE line1(idx) ' transfer buffer NEXT RETURN ' ------------------------------------------------------------------------- ' Transfers line 2 buffer to LCD ' -- makes no change in LCD screen position UPDATE_L2: TX_BYTE LcdI ' cursor to line 2, col 0 TX_BYTE LcdLine2 DELAY 1 FOR idx = 0 TO 15 TX_BYTE line2(idx) ' transfer buffer NEXT RETURN ' ------------------------------------------------------------------------- ' Updates the LCD with both line buffers UPDATE_LCD: TX_BYTE LcdI TX_BYTE LcdHome DELAY 1 UPDATE_L1 UPDATE_L2 RETURN :confused: :confused: ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=189836 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)