In SX Microcontrollers, SX/B Compiler and SX-Key Tool, robotworkshop wrote: Hello, I was working on one of my projects using SX/B and wanted an easy way to send debugging data to a PC to help see what was going on in my code. I used the built in RS-232 port on the SX48 DIP module kit to send data to the host PC. Sending a specific character is easy and has been shown quite a few times on this forum. I wanted a quick way to send the Hexidecimal representation of each byte to the Serial Port (followed by a space) and came up with the following code as another subroutine. It only has one byte passed to it and converts the value to be sent to the serial port for debugging. Just define BaudDbg as a constant like "T9600" and define DbgSer as the pin you want to use to send the debug data one. Also make sure to define the pin as an output! TX_ByteDbg SUB 1 ' Transmit character to debug port TX_ByteDbgHex SUB 1 ' Transmit Hex value to debug port . . . ' ------------------------------------------------------------------------- ' Use: TX_ByteDbg char ' -- 'Transmits 'char' over serial connection TX_ByteDbg: tmpB1 = __PARAM1 ' get the passed byte value SEROUT DbgSer, BaudDbg, tmpB1 ' Send the byte RETURN TX_ByteDbgHex: tmpB1 = __PARAM1 ' get the passed byte value tmpB2 = tmpB1 // 16 ' Get the low nybble digit (0-15) tmpB1 = tmpB1 / 16 ' Get the high nybble digit (0-15) tmpB1 = tmpB1 +$30 IF tmpB1 > $39 THEN tmpB1 = tmpB1 + 7 ENDIF tmpB2 = tmpB2 +$30 IF tmpB2 > $39 THEN tmpB2 = tmpB2 + 7 ENDIF SEROUT DbgSer, BaudDbg, tmpB1 ' Send the upper nybble SEROUT DbgSer, BaudDbg, tmpB2 ' Send the lower nybble SEROUT DbgSer, BaudDbg, 32 ' Send a trailing space RETURN I just wrote this code today as I needed something quick to help me debug a problem (which it did). I suppose it could be optimized a bit but perhaps some of you will find it useful. Best Regards, Robert ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=190314 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)