HSEROUT using STR modifier - length parameter as variable not working


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: HSEROUT using STR modifier - length parameter as variable not working

    it fails of course for more than 255 chrs

    Name:  roger.jpg
Views: 10945
Size:  159.9 KB



    Code:
    BalBuffer VAR BYTE[300]
    BalCount VAR word
    latb.7=1
    clear
    for   BalCount= 0 to 59
    BalBuffer[BalCount]=BalCount+"0"
    next
    
    
    for   BalCount= 1 to 59
    BalBuffer[BalCount+60]=BalCount+"0"
    next
    for   BalCount= 1 to 59
    BalBuffer[BalCount+120]=BalCount+"0"
    next
    for   BalCount= 1 to 59
    BalBuffer[BalCount+180]=BalCount+"0"
    next
    for   BalCount= 1 to 59
    BalBuffer[BalCount+240]=BalCount+"0"
    next
    BalBuffer[0]=13
    BalBuffer[60]=13
    BalBuffer[120]=13
    BalBuffer[180]=13
    BalBuffer[240]=13
    pause 2000
    debug "ready",13,10
    
    
    
    
    BalCount = 40
    HSEROUT ["40 ",STR BalBuffer\BalCount,13,10]
    debug   "40 ",STR BalBuffer\BalCount,13,10
    debug "full load "
    debug   STR BalBuffer,13,10
    HSEROUT ["full load ",STR BalBuffer,13,10]
    
    
    
    
    BalCount = 255
    HSEROUT ["255 ",STR BalBuffer\BalCount,13,10]
    HSEROUT [13,10]
    HSEROUT ["260"]
    BalCount = 260
    HSEROUT [STR BalBuffer\BalCount,13,10]
    end
    Last edited by richard; - 22nd February 2021 at 10:29.
    Warning I'm not a teacher

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: HSEROUT using STR modifier - length parameter as variable not working

    it fails of course for more than 255 chrs
    Of course, since the macro only uses the low byte of R4 to index the array. That would also make it fail when using a constant >255.

    In any case, the "example" posted in the first place had a BYTE sized variable with a value of 40 and everything we've seen this far is that it should (and ideed does, for 18F at least) work. I think I compiled for 16F628 when I looked at the .lst yesterday.

    flotulopex,
    You're going to have to post code that we can just compile, assemble and program into a chip that shows the problem.

  3. #3
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default HSEROUT using STR modifier - length parameter as variable not working

    Quote Originally Posted by HenrikOlsson View Post
    flotulopex,
    You're going to have to post code that we can just compile, assemble and program into a chip that shows the problem.
    Yup, I will do so asap.... Sorry, didn't have much time yesterday.
    Roger

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: HSEROUT using STR modifier - length parameter as variable not working

    Charles replied:

    Yes, I believe it can be trusted with a variable. I've used this form to receive a variable number of characters based on a length parameter received immediately prior to the string:

    [wait($80),length,STR idstring\length]


    So officially it is valid syntax.

    Ioannis

  5. #5
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default Re: HSEROUT using STR modifier - length parameter as variable not working

    For now, here a my two test programs with 16F690 and 18F1220.

    Surprisingly (to me), both accept the STR length as variable in the 3 ways I'm using it (HSEROUT, SEROUT2 and DEBUG).

    I'll go back to my current program and try again....
    Attached Files Attached Files
    Roger

Similar Threads

  1. Determining variable length (number of digits) possible?
    By CuriousOne in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 21st December 2020, 20:05
  2. Measuring a variable freq/length pulse and generating more pulses.
    By retepsnikrep in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 18th September 2014, 09:10
  3. hserout not working with parity
    By Pic2008 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 24th March 2010, 13:25
  4. HSERIN for variable length string
    By Pic2008 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 19th February 2010, 05:58
  5. Serin2 and STR Modifier
    By _Ian in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 22nd June 2005, 16:25

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