Searching \ for '[SX] Going Crazy, I can't send a word variable' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/ubicom/devices.htm?key=sx
Search entire site for: 'Going Crazy, I can't send a word variable'.

Exact match. Not showing close matches.
PICList Thread
'[SX] Going Crazy, I can't send a word variable'
2007\03\16@020026 by Capt. Quirkn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Capt. Quirk wrote:

Main problem is with the Word value RPM. For some reason I can't pass it from my "count" routine to the sub
LCD_Digit_Value. The Byte Value ADD1 has no problem though.



Thanks


' =========================================================================
'
'   File...... Parallel LCD v.01
'   Purpose... 8 Bit Parallel LCD Controller
'   Author....

'   E-mail....
'   Started... 12 Mar 2007
'   Updated... 16 Mar 2007
'
' =========================================================================
' -------------------------------------------------------------------------
' Program Description
' -------------------------------------------------------------------------
'
'  8 bit Parallel LCD controller using the SX28 for debuging purposes.

'--------------------------------------------------------------------------
' Program Notes
'--------------------------------------------------------------------------
'_03-12-07 Realized the need for the MSB pointer with a 7 bit Hex address
'_converted to a binary # to address the cursor location.
'_03-13-07 Need to put the start-up lcd information at the bottom of the
'_program and bring it up with Read-Data staments.
' -------------------------------------------------------------------------
' Device Settings
' -------------------------------------------------------------------------
DEVICE          SX28, OSCHS2, TURBO, STACKX, OPTIONX
FREQ          4_000_000
ID              "SLCD"
' -------------------------------------------------------------------------
' IO Pins
' -------------------------------------------------------------------------
lcd_control VAR RA
Lcd_RS  VAR RA.3  ' 0 = instruction, 1 = data
RW  VAR RA.2  ' 0 = write, 1 = read
Lcd_E  VAR RA.1  ' 1,1-->0 is the LCD enable lcd_data VAR  RB
lcd_DB7  VAR RB.7  ' DB7 = Data bus line 7 (MSB)
SpeedIn  PIN RC.0
' -------------------------------------------------------------------------
' Constants
' -------------------------------------------------------------------------
ADD1   Con %10000100
' -------------------------------------------------------------------------
' Variables
' -------------------------------------------------------------------------
idx  Var Byte
pos  Var Byte
char  Var Byte
tmpB1           VAR     Byte                    ' work vars
tmpW1           VAR     Word
tmpB2           VAR     Byte
tmpB3           VAR     Byte
rps  var byte
rpm  var word
' =========================================================================
 PROGRAM Start
' =========================================================================
WATCH tmpW1, 16, UDEC
WATCH idx, 8, UDEC
WATCH tmpB1,8, UBIN
WATCH rps,8, UDEC
WATCH RPM,16, UDEC
'WATCH R4,8, UDEC
'WATCH R5,8, UDEC
' -------------------------------------------------------------------------
' Subroutine Declarations
' -------------------------------------------------------------------------
Wait_Busyflag    SUB 0
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_Digit_Value  SUB 2, 3        
nopdel   SUB 0
LCD_ADDRESS  SUB 1
BREAK_NOW  SUB 0
' --------------------- ----------------------------------------------------
' Program Code
' -------------------------------------------------------------------------
'WORKING COPY WITH/out BUSY FLAG for 4 mhz, busy flag works best with faster
'resonators and should work here.

Start:
 TRIS_A = %0000
TRIS_B = %00000000
RW = 0                            ' RA.0 = input (serial)
LCDINIT
PAUSE 1000
'LCD_ADDRESS %10000000
PAUSE 100
For idx = 0 to 2
read Label_1 + idx, char
LCDOUT char
next
PAUSE 100
LCD_ADDRESS %10001010  'loc 3
PAUSE 100
For idx = 0 to 3
read Label_2 + idx, char
LCDOUT char
next
PAUSE 100
LCD_ADDRESS %10111000  'loc 5
PAUSE 100
For idx = 0 to 3
read Label_3 + idx, char
LCDOUT char
next
PAUSE 100
LCD_ADDRESS %11001010  'loc 7
PAUSE 100
For idx = 0 to 3
read Label_4 + idx, char
LCDOUT char
next
Pause 500

Main:

COUNT SpeedIn, 1000, rps
rpm = rps * 60  
LCD_5_Digit_Value rpm, ADD1     'RPM and ADD1 show up correct in the watch window
BREAK_NOW
PAUSEUS 1
goto Main
'---------------------------------------------------------------------------
'  473                  
'  474  01D2  0214        MOV __PARAM1,rpm_LSB           ;LCD_5_Digit_Value rpm, ADD1
 '      01D3  0028
  '475  01D4  0215        MOV __PARAM2,rpm_MSB          
'    '    01D5  0029
'  476  01D6  0C84        MOV __PARAM3,#ADD1            
 '      01D7  002A
  '477  01D8  0C03        MOV __PARAMCNT,#3            
'        01D9  002C
'  478  01DA  0010        CALL @__LCD_5_Digit_Value    
 '      01DB  0945
  '479                  

' --- = ----------------------------------------------------------------------
LCD_Digit_Value:                   I need this sub to manage 4 different values, but right now it only accepts a Byte value address.
IF __PARAMCNT = 3 then
tmpW1 = __WPARAM12        'Can't get RPM to fit into tmpW1?????
tmpB1 = __PARAM3                 'But down here only ADD1 makes it to tmpB1 endif
 LCD_ADDRESS tmpB1
BREAK_NOW
PAUSEUS 1
_10000:
idx = "0"
DO WHILE tmpW1 >= 10000
    tmpW1 = tmpW1 - 10000
idx = idx + 1
LOOP
pauseus 50
LCDOUT idx
BREAK_NOW
PAUSEUS 1
_1000:

idx = "0"
DO WHILE tmpW1 >= 1000
    tmpW1 = tmpW1 - 1000
idx = idx + 1
  LOOP
pauseus 50
LCDOUT idx
BREAK_NOW
PAUSEUS 1
_100:

idx = "0"
  DO WHILE tmpW1 >= 100
    tmpW1 = tmpW1 - 100
 idx = idx + 1
LOOP
pauseus 50
LCDOUT idx
BREAK_NOW
PAUSEUS 1
_10:
idx = "0"
  DO WHILE tmpW1 >= 10
    tmpW1 = tmpW1 - 10
idx = idx + 1
LOOP
pauseus 50
LCDOUT idx
BREAK_NOW
PAUSEUS 1
_1:
idx = "0"
  DO UNTIL tmpW1 = 0
    tmpW1 = tmpW1 - 1
idx = idx + 1
LOOP
pauseus 50
LCDOUT idx
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
' -------------------------------------------------------------------------
' Use: DELAY 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
' -------------------------------------------------------------------------
LCD_ADDRESS:                                         ' write command byte
 Lcd_RS = 0
 'lcd_DB7 = 1
  'nopdel
 GOTO Lcd_Put
'--------------------------------------------------------------------------
' Use: LCDCMD cmdByte
' -- send 'cmdByte' to LCD with RS line low
LCDCMD:                                         ' write command byte
 Lcd_RS = 0
  'nopdel
  'nopdel
 GOTO Lcd_Put
' -------------------------------------------------------------------------
' Use: LCDOUT char
' -- send 'char' to LCD with RS line high
LCDOUT:                                         ' write character byte
 Lcd_RS = 1
  'nopdel
  'nopdel
' -------------------------------------------------------------------------
Lcd_Put:                                        ' byte --> LCD bus
 lcd_data = __PARAM1
' -------------------------------------------------------------------------
BLIP:                                           ' move bus into LCD
 Lcd_E = 1
 nopdel
 Lcd_E = 0
 DELAY_US 40                                   ' instruction delay
 RETURN
' -------------------------------------------------------------------------
 
Wait_Busyflag:
 Lcd_RS = 0
REVERSE RW
REVERSE lcd_DB7
nopdel
 
Hold:
Lcd_E = 1
 nopdel
 Lcd_E = 0
 nopdel
 IF lcd_DB7 = 1 THEN Hold
 OUTPUT lcd_DB7
 LOW RW
 LOW Lcd_RS
'DELAY_US 200
RETURN                        
'----------------------------------------------------------------------------------------------
nopdel:
 ASM
 nop
 nop
 nop
 nop
 nop
 nop
 nop
 nop
 ENDASM
RETURN
'-------------------------------------------------------------------------
BREAK_NOW:
BREAK
RETURN
'------------------------------------------------------------------------------

' -------------------------------------------------------------------------
' Use: LCDINIT
' -- initialize LCD for 8-bit, 2-line interface

LCDINIT:
 DELAY 15                                      ' power-up delay, 15 ms
 TRIS_B = %00000000                          ' all outputs
 lcd_data = %00110000                            ' 8-bit interface
 BLIP
 DELAY 5                                       ' delay 4.5 ms (min)
 BLIP
 DELAY_US 100
 BLIP
 LCDCMD %00111000                              ' multi-line, 5x7 font
 LCDCMD %00001110                              ' display on, cursor on, Blink OFF
 LCDCMD %00000110                              ' auto-increment cursor
 LCDCMD %00000001                              ' clear and home LCD
 RETURN
' -------------------------------------------------------------------------
'--------------------------------------------------------------------------
Label_1:
DATA "RPM"  
Label_2:
DATA "SERV"  
Label_3:
DATA "CHT1"
Label_4:
DATA "CHT2"
'loc_3:
'DATA %10010000  '#2 LINE 1
'
'loc_5:
'DATA %10111000  '#4 LINE 2 / 0
'
'loc_7:
'DATA %11001010  '#6 LINE 2 / 10
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=178450
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)

More... (looser matching)
- Last day of these posts
- In 2007 , 2008 only
- Today
- New search...