In SX Microcontrollers, SX/B Compiler and SX-Key Tool, fiveslo wrote: JonnyMac: After I substituted the code that you suggested: [code]SUB AD_READ: LOW ADcs adChan = adChan << 8 SHIFTOUT SDO, SClk, MSBFIRST, adChan\12 SHIFTIN SDI, SClk, MSBPRE, result\12 HIGH ADcs tmpW1 = result ** 14464 result = result + tmpW1 ENDSUB[/code] I get a "Error 11, BYTE VARIABLE EXPECTED "result" on the line, SHIFTIN SDI, SClk, MSBPRE, result\12 . I scanned thru the help file of SX/B and found something which caught my eye, that being the \COUNT parameter of SHIFTIN and SHIFTOUT, ranges from 1-8, is this true or was this an update when WORD VARs were added to SX/B? In any case I substituted as I think you suggested: [code] SHIFTIN sdi,sclk,MSBPRE,result_MSB\4 ' get result, 12 bits SHIFTIN sdi,sclk,MSBPRE,result_LSB [/code] What I see in the watch window is a 12bit result, yet kind of weird... in the case that the range goes from 0 to +2048, and when +2048 rolls over it changes to -2048 and goes back down to 0 counting the whole way negatively.. does that make sense?? I'm seeing the 0-4095 range however, not in a 0-4095 way, rather in a 0-2048 then -2048-0... is my WATCH statement responsible for this... [code]WATCH result,12,SDEC[/code] I'm guessing yes, if so how do I fix this??? As for the code: [code] tmpW1 = result ** 14464 result = result + tmpW1 [/code] will this work with the result_LSB and result_MSB mods to result? Reason I ask is this part after my _LSB and _MSB mods didn't make the compiler happy... I've posted my refined but still not working code below... Thanks again for your input.. Rob [code]Start: HIGH ADcs ' make CS output LOW sclk ' make clock 0-1-0 [code]Main: DO LOW ADcs ' select chip ADch=$b ' make dummy conversion to intialize converter GOSUB ADread ADch=0 ' acquire TLC2543 channel 0 GOSUB ADread BREAK() ' update result variable in watch window LOOP END [code]ADread: LOW ADcs ADch=ADch<<8 [code]SHIFTOUT sdo,sclk,MSBFIRST,ADch\12 ' Can the \COUNT be greater than 8, instructions for SX/B say no! 'SHIFTIN sdi,sclk,MSBPRE,result\12 ' <--- Error 11, BYTE VARIABLE EXPECTED "result" COMPILER GENERATED ERROR! [code] SHIFTIN sdi,sclk,MSBPRE,result_MSB\4 ' get result, 12 bits SHIFTIN sdi,sclk,MSBPRE,result_LSB HIGH ADcs ' deselect chip [code] RETURN [code] [/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=183991#m184196 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)