HSERIN qualifier


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Code:
         HSERIN [HEX X]
         HSEROUT [DEC X.7,13]
         HSEROUT [DEC X.6,13]
         HSEROUT [DEC X.5,13]
         HSEROUT [DEC X.4,13]
         HSEROUT [DEC X.3,13]
         HSEROUT [DEC X.2,13]
         HSEROUT [DEC X.1,13]
         HSEROUT [DEC X.0,13]
         HSEROUT ["BIN",13]
         HSEROUT [BIN X,13]
    Attached Images Attached Images  
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Thanks guys,

    The routine below is supposed to take comma-delimited strings and convert them to binary. It should handle the sequence 02,A,A2 for example, properly.

    Code:
    Preparser:
         HSERIN [Wait (":")]  ; wait for colon to start  
    GrabAscii:
    
          HSERIN 500,NoMoreInput,[ASCIN [Y]]   ; Load it into small array, first char goes into element zero
           
           IF ASCIN [Y] = "," THEN ; Found a comma   This will never be in element zero , but 
                                   ; may exist in element 1
                     
                     SELECT CASE Y
                         CASE 1
                            MSB = 0
                            LSB = ASCIN[Y-1]
                          CASE 2
                            MSB = ASCIN[Y-2]
                            LSB = ASCIN[Y-1]
                          CASE ELSE
                            HSEROUT ["INPUT ERROR"]
                              PAUSE 2500
                          END SELECT    
                     
                     GOSUB IHEX2BIN      
                      
                     OUTARRAY[Z] = ByteVal    ; load variable into array
                     Z = Z + 1
                     Y = 0                 ; Clear Y if we found a comma
            ENDIF
            Y = Y + 1
             
            Goto GrabAscii
            
                       
    NOMoreInput:
    
      ......
    
    
    ';**************************************************************
    '; Routine takes HEX Ascii chars 
    '; and converts to BIN
    '; Inputs MSB, LSB ("0" to "F")
    '; Outputs ByteVal 
    ';***************************************************************
    IHEX2BIN:
             LOOKDOWN MSB,["0123456789ABCDEF"],ByteValH
             LOOKDOWN LSB,["0123456789ABCDEF"],ByteValL
             ByteVal = (ByteValH << 4) + ByteValL
             RETURN
    ';***************************************************************


    It is nearly 4 A.M here in CA. Time to go to work and see how the code works!
    Charles Linquist

Similar Threads

  1. timeout of Hserin, goto, gosub or both?
    By flipper_md in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 28th October 2009, 18:43
  2. TMR0 interrupt and HSERIN
    By boban in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd September 2008, 11:48
  3. 16F877a Interupt driven Hserin
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd November 2006, 00:38
  4. Can a TMR interrupt stops HSERIN?
    By SergioRM in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 24th January 2006, 01:07
  5. Hserin
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th November 2004, 15:42

Members who have read this thread : 0

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