Shop OBEX P1 Docs P2 Docs Learn Events
Sending Binary or Hex values to PC using Serout? — Parallax Forums

Sending Binary or Hex values to PC using Serout?

gtslabsgtslabs Posts: 40
edited 2007-12-15 00:48 in General Discussion
I am trying to send a word value to my PC from the SX48
I am breaking it down into cntr_LSB and cntr_MSB and using:
SEROUT TX, Baud, cntr_lsb SEROUT TX, Baud, cntr_msb


But I am receiving the Ascii character not the value of the variable.
Can this be sent out as a HEX or Binary value?

Also I clocked each Serout statement to be 2.1 ms with my 4mhz osc and the Sim.
I am using these statements in an interrupt that triggers as fast as every 1 ms
from:
PulsePin    PIN  RB.7  INPUT INTR_RISE ' Interrupt on rising edge

·
INTERRUPT NOPRESERVE
' =========================================================================
  WKPND_B = 0 ' Clear interrupt pending bit (Do this FIRST)
  INC cntr

 
      'If cntr=0 then 
          ' Inc Cntr2 
       'endif

SEROUT TX, Baud, cntr_lsb
SEROUT TX, Baud, cntr_msb
 
'SEROUT TX, Baud, cntr2_lsb'SEROUT TX, Baud, cntr2_msb
 

RETURNINT


What options do I have for sending out these values faster? I must keep my 4mhz osc.

Comments

  • JonnyMacJonnyMac Posts: 9,217
    edited 2007-12-13 00:39
    Are you sure you're getting ASCII characters? You might check on how you're assembling the value at the other end, because your process for sending a word from the SX to the PC is correct (though I wouldn't stick a SEROUT in the middle of an INTERRUPT).
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-12-14 01:43
    gtslabs said...
    Can this be sent out as a HEX or Binary value?
    Strictly speaking, yes. You can convert your numbers into another format before sending them. However, if you are concerned about transmission speed you will not want to do that. To represent each byte that you are sending now using two ASCII characters for the hex values would take twice as long to transmit. To send the ASCII characters for a binary representation would increase your transmission time eight fold. I do not think you want to do that!
    gtslabs said...
    What options do I have for sending out these values faster? I must keep my 4mhz osc.
    Since you did not disclose the baud rate you are presently using, the first thing to do is make sure you are using the fastest baud rate possible for your setup.

    Also, is it really necessary to send the count value each time you increment the count? Maybe you could increment the count and set a “There is a New Count Available” flag in your interrupt routine. Then have your main program check this flag periodically. If it is set, clear it and send the newest count value. This will allow you to count much faster than your present arrangement, which is hindered by the speed at which you can send the data.

    There may well be other solutions available to you. However, I think most people will require more information about what you are trying to accomplish before they can offer any meaningful help.

    - Sparks
  • T'SaavikT'Saavik Posts: 60
    edited 2007-12-15 00:48
    If you haven't discovered it already, you may want to checkout realterm.sourceforge.net/ also.

    It made my serial adventures much nicer [noparse]:D[/noparse]
Sign In or Register to comment.