Going crazy, can't pass a word variable to a sub routine
Capt. Quirk
Posts: 872
The sub "LCD_5_Digit_Value·SUB·2, 3" will not pass·the first Word value "rpm", but it does pass the Byte value "ADD1"
I am pretty·certain the top of the sub·is wrong, but I have changed it many times and been unable to correct it. Included a .lst code snipet.
The sub has been tested many times with a Static Value, but when I added it to the LCD routine it won't work. But I am sure it would if the sub recieved the data.
Thanks
I am pretty·certain the top of the sub·is wrong, but I have changed it many times and been unable to correct it. Included a .lst code snipet.
The sub has been tested many times with a Static Value, but when I added it to the LCD routine it won't work. But I am sure it would if the sub recieved the data.
Thanks
Comments
I suspect that your rps variable ought to be a WORD variable. I have encountered similar situations where SX/B math operations preformed with a mix of WORD and BYTE variables did not produce the expected results.
Also... I noticed that you have a LOT of pauses in your program. Maybe you put them there to help see what is going on or to be extra-cautious with your timing. That is fine. What happens, though, is that each use of the 'Pause' statement gets replaced with several lines of assembly instructions when the program is compiled. (For more information see JonnyMac's comments in this thread.)
To see what a difference this can make, compile your program as usual, then go to Run | Device and scroll the E2FLASH window all the way down to the bottom. Then slowly start scrolling the window back up to the top noting the relative amount of 'FF' entries. The 'FF' entries indicate the free space remaining in your program memory. Then replace all of your 'Pause' statements with a call to a subroutine with 'Pause' in it just once, such as JonnyMac's DELAY_MS subroutine reference above. I think you will be amazed by the program size difference!
I hope this helps.
- Sparks
Now you can pass your first parameter as a word or byte. Just a note: if that second parameter is the address of where to write the string you have to use tmpB1; you code is currently doing this:
It doesn't look like tmpB3 is being set before the call to the subroutine.
Post Edited (JonnyMac) : 3/16/2007 10:36:19 PM GMT
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
If anybody else can use it, here it is
Thanks again