In SX Microcontrollers, SX/B Compiler and SX-Key Tool, tdg8934 wrote: I'm not sure if this is what you are looking for but JonnyMac wrote this routine sometime back which helped me: [code] ' Use: value = BITVAL someVal, position ' -- "someVal" can be a byte or word FUNC BITVAL IF __PARAMCNT = 2 THEN ' byte passed? tmpW1 = __PARAM1 ' get byte value tmpB1 = __PARAM2 ' get bit position ELSE ' word passed tmpW1 = __WPARAM12 ' word was passed tmpB1 = __PARAM3 ' get bit position ENDIF tmpB2 = 0 ' assume cleared IF tmpB1 >= 0 THEN ' position value legal? IF tmpB1 <= 15 THEN tmpW2 = 1 << tmpB1 ' create bit mask tmpW2 = tmpW2 & tmpW1 ' clear other bits IF tmpW2 > 0 THEN ' if not zero tmpB2 = 1 ' bit was 1 ENDIF ENDIF ENDIF RETURN tmpB2 ENDFUNC [/code] You use it like this: [code]data1 VAR Word data2 VAR Word data3 VAR Word [code]value VAR Byte [code]I VAR Byte [code] CheckDataSin: For I = 0 to 15 [b]value = BITVAL data1, I[/b] IF value = 1 THEN HIGH SIN_1 ELSE LOW SIN_1 ENDIF value = BITVAL data2, I IF value = 1 THEN HIGH SIN_2 ELSE LOW SIN_2 ENDIF value = BITVAL data3, I IF value = 1 THEN HIGH SIN_3 ELSE LOW SIN_3 ENDIF HIGH CLOCK LOW CLOCK NEXT Also keep an eye out when SX/B 2.0 is released for something to help you on this also. [/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=301741#m301759 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)