In SX Microcontrollers, SX/B Compiler and SX-Key Tool, threepointone wrote: I don't have access to my setup at the moment--I'd rather double check to give a better diagnosis of what works and what doesn't before I post the code (it's really, really long). However, I did notice something interesting going on in the assembly listing. [code] 1378 =00000019 LCD_TempStr EQU 0x19 ;LCD_TempStr Var Word 1379 =00000019 LCD_TempStr_LSB EQU LCD_TempStr 1380 =0000001A LCD_TempStr_MSB EQU LCD_TempStr+1 1381 1382 =0000002C LCDVars EQU 0x2C ;LCDVars Var Byte(5) 1383 1384 =0000002C LCD_Temp1 EQU LCDVars+0 ;LCD_Temp1 Var LCDVars(0) 1385 1386 =0000002D LCD_TempHex EQU LCDVars+1 ;LCD_TempHex Var LCDVars(1) 1387 1388 =0000002E LCD_TempHexChar EQU LCDVars+2 ;LCD_TempHexChar Var LCDVars(2) 1389 1390 =00000030 LCD_TempCharCnt EQU LCDVars+4 ;LCD_TempCharCnt Var LCDVars(4) 1391 1392 =0000002F LCD_TempChar EQU LCDVars+3 ;LCD_TempChar Var LCDVars(3) 1393 [/code] The variable that was causing problems, LCD_TempCharCnt, happens to overflow to the next bank in the array. I'm not really sure how that'd mess up with indirect addressing, but it's something interesting to note. By the way, I'm running on an SX48. here's the actual code that appears to be causing the problem. The problem that occurs is too consistent to describe without all of the code. It might have to do with the I2C bus commands somewhere, as putting pauses in certain places in the main code magically made everything work again (a whole lot slower, of course). Again, changing LCD_TempCharCnt to a global variable fixed everything in the code. Unfortunately, my SX-Key is a bit defective and won't debug anything (I'm doing an RMA after this project is done), so that makes things a bit more difficult to figure out. A lot of the functions require an actual I2C device to be connected, so I can't really do this in SXSim [code] ' parameters: character (Byte), # of characters (Byte) ' LCD_I2Cxxxx commands are elsewhere in the code LCD_DispChar: LCD_TempChar = __Param1 If __ParamCnt = 1 then LCD_TempCharCnt = 1 else LCD_TempCharCnt = __Param2 endif LCD_I2CStart LCD_DataMode Do LCD_I2CSend LCD_TempChar LCD_TempCharCnt = LCD_TempCharCnt - 1 if LCD_TempCharCnt = 0 then exit Loop LCD_I2CStop Return [/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=246928#m246958 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)