In SX Microcontrollers, SX/B Compiler and SX-Key Tool, smhhadima wrote: Every time I try to compile this code the new compiler CRASH!!! (I get windows error screen) the other codes compiles fine ' ------------------------------------------------------------------------- ID "MasterUint" DEVICE SX28, OSCXT2, BOR42 FREQ 20_000_000 STACK 16 ' ------------------------------------------------------------------------- ' I/O Pins ' ------------------------------------------------------------------------- ' =====================================Sio PIN Rc.2 INPUT ' pull-up via 4.7K LcdE PIN Rc.0 ' pull-down via 4.7K LcdRS PIN Rc.1 TRIS_Ctrl VAR TRIS_c LcdBus PIN RA TRIS_Lcd VAR TRIS_A ' ------------------------------------------------------------------------- ' Constants ' ------------------------------------------------------------------------- Baud CON "OT9600" ' open for single wire Cmd CON $FE ' LCD command prefix ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- serByte VAR Byte ' serial IO byte tmpB1 VAR Byte ' work vars tmpB2 VAR Byte tmpW1 VAR Word==================================== PROGRAM Start ' ========================================================================= ' ------------------------------------------------------------------------- ' Subroutine Declarations ' ------------------------------------------------------------------------- DELAY SUB 1, 2 ' delay in milliseconds DELAY_US SUB 1, 2 ' delay in microseconds BLIP SUB 0 ' move bus to/from LCD LCDINIT SUB 0 ' initialize LCD LCDCMD SUB 1 ' command byte --> LCD LCDOUT SUB 1 ' byteVar --> LCD LCD_PUT SUB 1 ' byteVar --> LCD RX_BYTE FUNC 1 ' rx from serial I/O TX_BYTE SUB 1 ' tx to serial I/O ' ------------------------------------------------------------------------- ' Program Code ' ------------------------------------------------------------------------- Start: TRIS_Ctrl = %0100 ' Rc.2 = input (serial) LCDINIT Main: serByte = RX_BYTE ' wait for byte IF serByte = Cmd THEN Do_Command ' command? Do_Write: LCDOUT serByte ' no, write char byte GOTO Main Do_Command: serByte = RX_BYTE ' get command byte IF serByte = Cmd THEN Extended_Cmd ' extended command? LCDCMD serByte ' no, write cmd byte GOTO Main Extended_Cmd: serByte = RX_BYTE ' get extended command Set_IO: IF serByte <> $F0 THEN Read_IO ' check command serByte = RX_BYTE ' get port configuration TRIS_IO = serByte ' setup IO port GOTO Main Read_IO: IF serByte <> $F1 THEN Write_IO DELAY 2 ' delay for host setup TX_BYTE IoPort ' send port bits to host GOTO Main Write_IO: IF serByte <> $F2 THEN Read_Byte IoPort = RX_BYTE ' put bits on the port GOTO Main Read_Byte: IF serByte <> $FF THEN Cmd_X serByte = LCDIN ' read LCD (cursor pos) DELAY 2 ' delay for host setup TX_BYTE serByte ' send byte to to host GOTO Main Cmd_X: ' for future expansion ' GOTO Main ' ------------------------------------------------------------------------- ' Subroutine Code ' ------------------------------------------------------------------------- ' Use: DELAY ms ' -- 'ms' is delay in milliseconds, 1 - 65535 SUB DELAY IF __PARAMCNT = 1 THEN tmpW1 = __PARAM1 ' save byte value ELSE tmpW1 = __WPARAM12 ' save word value ENDIF PAUSE tmpW1 ENDSUB ' ------------------------------------------------------------------------- ' Use: DELAY us ' -- 'us' is delay in microseconds, 1 - 65535 SUB DELAY_US IF __PARAMCNT = 1 THEN tmpW1 = __PARAM1 ' save byte value ELSE tmpW1 = __WPARAM12 ' save word value ENDIF PAUSEUS tmpW1 ENDSUB ' ------------------------------------------------------------------------- ' Use: LCDCMD cmdByte ' -- send 'cmdByte' to LCD with RS line low SUB LCDCMD ' write command byte LcdRS = 0 Lcd_Put __PARAM1 ENDSUB ' ------------------------------------------------------------------------- ' Use: LCDOUT char ' -- send 'char' to LCD with RS line high SUB LCDOUT ' write character byte LcdRS = 1 Lcd_Put __PARAM1 ENDSUB __PARAM1 ' ------------------------------------------------------------------------- SUB Lcd_Put ' byte --> LCD bus LcdBus = __PARAM1.high BLIP ENDSUB ' ------------------------------------------------------------------------- SUB BLIP ' move bus into LCD LcdE = 1 DELAY_US 2 LcdE = 0 DELAY_US 40 ' instruction delay ENDSUB ' ------------------------------------------------------------------------- ' Use: char = LCDIN ' -- puts value at LCD cursor position in 'char' FUNC LCDIN TRIS_Lcd = %11111111 ' make LCD bus inputs LcdRS = 1 ' character mode LcdRW = 1 ' read mode LcdE = 1 ' move byte to bus tmpB1 = LcdBus ' grab the byte LcdE = 0 ' complete the read LcdRW = 0 ' return to write mode TRIS_Lcd = %00000000 ' make LCD bus outputs RETURN tmpB1 ' return byte to caller ENDFUNC ' ------------------------------------------------------------------------- ' Use: LCDINIT ' -- initialize LCD for 8-bit, 2-line interface SUB LCDINIT: DELAY 15 ' power-up delay, 15 ms TRIS_Lcd = %0000 ' all outputs LcdBus = %0010 ' 4-bit interface BLIP DELAY 5 ' delay 4.5 ms (min) BLIP DELAY_US 100 BLIP LCDCMD %00111000 ' multi-line, 5x7 font LCDCMD %00001100 ' display on, no cursor LCDCMD %00000110 ' auto-increment cursor LCDCMD %00000001 ' clear and home LCD ENDSUB ' ------------------------------------------------------------------------- ' Use: char = RX_BYTE ' -- reads byte from serial input and places in 'char' FUNC RX_BYTE SERIN Sio, Baud, tmpB1 ' receive a byte RETURN tmpB1 ' return to caller ENDFUNC ' ------------------------------------------------------------------------- ' Use: TX_BYTE char ' -- transmits 'char' over serial connnection SUB TX_BYTE tmpB1 = __PARAM1 ' save byte to send SEROUT Sio, Baud, tmpB1 ' send the byte ENDSUB ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=2&m=323767#m350992 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)