Strange HSEROUT execution times


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343

    Question Strange HSEROUT execution times

    I was curious how long it would take to output a data series to my PC. So I set up some code for a test. I am using an 18F4620 @ 40MHz and 38400 baud. The Storeout() array is initialized with values between 33-122 (printable ASCII). I then used Darrel's code from this thread to time the output. Here are the key lines from my code:
    Code:
        gosub ClearTimer1
    @ bsf     T1CON, TMR1ON   ' Start timer
        for count = 0 to 527
              hserout [Storeout(count)]
        next eccrow
    @ bcf     T1CON, TMR1ON   ' Stop timer
        Hserout ["Serial Out Time  = "]
        Gosub ShowTime
    Now, here is the strange thing. As above, it takes 4099.4uS to execute (with no variation regardless of actual values being sent). However, if I change the HSEROUT line by adding an additional value, like so:

    hserout [Storeout(count),0]

    it only takes 1641.8uS to execute (with any value after the comma).
    Note: Everything else about this works exactly as expected.

    Any ideas why this is happening?

    Steve B

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    the main difference reside in the overflow of TMR1 + time to send a Byte. Do the same thing but remove the For To Next loop... how about now?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Duhh

    Thanks steve. It was late, my eyes were crossed and I could not see the forest for all the trees! I played with the prescale and overflow/interupt flag and got something workable.

    Steve B

Similar Threads

  1. I2C Slave with a PIC
    By ralfmayr in forum mel PIC BASIC Pro
    Replies: 129
    Last Post: - 21st August 2016, 17:44
  2. HSEROUT and Commas, What? Help Me Understand
    By altech6983 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 20th July 2009, 19:12
  3. Is HSEROUT corrupting bit 7 ?????
    By Robert Wells in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd October 2008, 16:26
  4. Strange HSEROUT behaviour
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 7th July 2006, 23:37
  5. pic18f252 hserout some times is incomplete
    By edysan in forum Serial
    Replies: 5
    Last Post: - 20th June 2006, 23:55

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