Menu

Unsure on to get this to work

Help
2009-05-22
2013-05-30
  • Nobody/Anonymous

    Say I have:

    A = "F"
    B = "8"
    dim variableA as byte
    dim variableB as byte
    dim combinedAB as word
    combinedAB = B
    combinedAB_H = A

    xmit_rs232 (h'combinedAB')

    but I am sure that the last part is not correct, I need "F8" output in hex

     
    • kent_twt4

      kent_twt4 - 2009-05-22

      Not going to do it.  xmit_rs232 is only going to transmit one byte at a time.  Check out Hugh's LCD Hex() sub in the include/lowlevel/lcd.h file.  Just substitute xmit_rs232() to write the byte for each hex nibble:

      Main:
      xmit_rs232(0x0D) ;carriage return
      xmit_rs232(0x0A) ;line feed
      SerialHex(0x9F) ;dec 159
      xmit_rs232(0x0D) ;carriage return
      xmit_rs232(0x0A) ;line feed
      wait 1 s
      for testhex = 1 to 15
      if testhex <= 9 then bin2ascii testhex
      if testhex = 10 then Xmit_Print "A"
      if testhex = 11 then Xmit_Print "B"
      if testhex = 12 then Xmit_Print "C"
      if testhex = 13 then Xmit_Print "D"
      if testhex = 14 then Xmit_Print "E"
      if testhex = 15 then Xmit_Print "F"
      wait 1 s
      next
      goto Main

      sub SerialHex(In Value)
          ValueTemp = 0
         
          IF Value >= 0x10 then
              ValueTemp = Value / 0x10
              Value = Value % 0x10
              if ValueTemp > 9 then ValueTemp = ValueTemp + 7
              xmit_rs232 (ValueTemp + 48) ;upper nibble
          end if
         
          ValueTemp = Value
          if ValueTemp > 9 then ValueTemp = ValueTemp + 7
          xmit_rs232 (ValueTemp + 48) ;lower nibble
         
      end sub

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.