In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Capt. Quirk wrote: [quote="It doesn't look like tmpB3 is being set before the call to the subroutine."] [/quote]Yea, Every time I call a subroutine from "LCD_5_Digit_Value" it returns tmpW1 as a byte value. So I tried moving LCD_ADDRESS one line before the calling LCD_5_Digit_Value in the main program loop and that didn't work either. Then I moved it above the COUNT line and it worked fine. Then I uncomented my "LCDOUT idx" lines, so I could display the values and as soon as it returns from the first "LCDOUT", tmpW1 is modified to a byte again. Bean helped me out with this earlier and gave me this snipet, But never got it to work. Last week I trimed it down and it worked fine within testing of the SX-Key debug. But as soon as I added to the program, I started having problems. Now I think I see why Bean had this at the bottom of the program? There are some parts of this routine that are still beyond my ability. Is it necessary to use the "GOSUB" within a Subroutine? I am posting a cleaner version of my program and the cut down version of Bean's snipet Thanks everybody digits(4) = digits(4) + value_LSB ' Blank leading zeros idx = 0 DO WHILE idx < 4 IF digits(idx) = "0" THEN ' IF digit is Zero... digits(idx) = " " ' make it Blank ELSE idx = 4 ' Set counter to done value ENDIF INC idx LOOP ' Send digits to LCD FOR idx = 0 TO 4 char = digits(idx) GOSUB LCD_Write NEXT [/quote] [b] ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- digits VAR Byte (5) ' holds digits for display '--------------------------------------------------------------------------------- LCD_Put_RJ_Value: ' Init digits to all zeros PUT digits, "00000" ' Convert value to ascii digits DO WHILE value >= 10000 INC digits(0) value = value - 10000 LOOP DO WHILE value >= 1000 INC digits(1) value = value - 1000 LOOP DO WHILE value >= 100 INC digits(2) value = value - 100 LOOP DO WHILE value >= 10 INC digits(3) value = value - 10 LOOP digits(4) = digits(4) + value_LSB ' Blank leading zeros idx = 0 DO WHILE idx < 4 IF digits(idx) = "0" THEN ' IF digit is Zero... digits(idx) = " " ' make it Blank ELSE idx = 4 ' Set counter to done value ENDIF INC idx LOOP ' Send digits to LCD FOR idx = 0 TO 4 char = digits(idx) GOSUB LCD_Write NEXT RETURN [/b] [/quote] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=178452#m178653 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)