Hi,
A bit convoluted but it hopefully shows what's happening:OrCode:Temp = PortB.0 & %11110001 ' Read PortB into Temp and clear bits 1-3 ( & is bitwise AND) Value = 5 ' This is the value that will be written to bits 1-3 Value = Value << 1 ' Shift value to the left one place to "align it" with bits 1-3 PortB = Temp | Value ' Write new value back to PortB. ( | is bitwise OR )Or, if a bit bitflipping on the port doesn't matterCode:Temp = PortB.0 Value = 5 Temp.1 = Value.0 Temp.2 = Value.1 Temp.3 = Value.2 PortB.0 = TempAnd I'm sure there are other ways.Code:Value = 5 PortB.1 = Value.0 PortB.2 = Value.1 PortB.3 = Value 2
/Henrik.




Bookmarks