Using HSEROUT to send decimal string


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2006
    Posts
    60

    Default Using HSEROUT to send decimal string

    I'm trying to send a string of 9 bytes out in decimal form see code below. I don't know if I can do the decimal string.Using PBP3 and a 16F690

    Code:
     define OSC 4
     
    '-----------------------Enable EUSART------------------------------------
     
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    DEFINE HSER_SPBRG 51  ' 4800 Baud @ 4MHz, 0.17%
    SPBRGH = 0
    BAUDCTL.3 = 1         ' Enable 16 bit baudrate generator 
     
    '-----------------------REGISTERS----------------------------------------
    
    TRISA=%001000                                                   ' RA0,RA3,RA4,RA5 inputs
    ANSEL=%00000000                                                 ' All digital
    ANSELH=$0000                                                    ' AN11, rest digital
    TRISB=$00                                                       ' All pins output
    TRISC=%00000000                                                 ' RC5 input 
    CM1CON0.7=0                                                     ' Shut off comparators
    CM2CON0.7=0                                                     ' Shut off comparators
    OPTION_REG.7=0
    WPUA=%001000                                                    ' Weak Pull Ups Enabled
    
    track var PORTA.3
    
    rottime var byte[9]
    rot1time var rottime[0]
    rot2time var rottime[1]
    rot3time var rottime[2]
    rot4time var rottime[3]
    rot5time var rottime[4]
    rot6time var rottime[5]
    rot7time var rottime[6]
    rot8time var rottime[7]
    rot9time var rottime[8]
    rot10time var rottime[9]
     
     Main:
                   if track=0 then
                         rot1time=1
                         rot2time=2
                         rot3time=3
                         rot4time=4
                         rot5time=5
                         rot6time=6
                         rot7time=7
                         rot8time=8
                         rot9time=9
                         rot10time=10
                         hserout [str rottime\9,13,10]
                        pause 500 
                      endif
                      goto main

  2. #2
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

    Default Re: Using HSEROUT to send decimal string

    Quote Originally Posted by mel4853 View Post
    I'm trying to send a string of 9 bytes out in decimal form see code below. I don't know if I can do the decimal string.Using PBP3 and a 16F690
    Try:
    Code:
     
    FOR i = 0 TO 8
      HSEROUT [rottime[i]]
    NEXT
    HSEROUT [rottime[9],10]
    Norm

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: Using HSEROUT to send decimal string

    If the array is already containing the ASCII code for the character you want to send then that will work but by your description and code it sounds like the array can contain values from 0-255 and that it is the decimal representation of those values you want to send - as ASCII?

    Ie. if the array contains the value 65 it's '65' you want to see on your terminal - not 'A' which is the ASCII character for the decimal value 65.

    Perhaps what you're looking for is more in the line of:
    Code:
    Main:
      if track=0 then
        rot1time=1
        rot2time=2
        rot3time=3
        rot4time=4
        rot5time=5
        rot6time=6
        rot7time=7
        rot8time=8
        rot9time=9
        rot10time=10
    
        FOR i = 0 to 0                     
          hserout [DEC rottime[i]]
        NEXT
        HSEROUT[10,13]
    
        pause 500 
      endif
    /Henrik.

Similar Threads

  1. String of characters(array) to decimal value
    By tacbanon in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 20th June 2012, 14:30
  2. Array of string to send with TX int ?
    By amgen in forum General
    Replies: 18
    Last Post: - 18th August 2011, 16:56
  3. How to send a string with another string inside it?
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 13th May 2011, 17:11
  4. How to send a binary string on an output?
    By Robson in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 25th July 2007, 22:54
  5. Decimal values from string
    By GioppY in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th November 2005, 21:10

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts