Skip incoming bytes in SERIN


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Alexey View Post
    SERIN PORTB.3,T2400,4000,CLR,[85],VAR,VAR,VAR,VAR,VAR,VAR,VAR,VAR,VAR,VAR

    Skipping 9 bytes cost me 45 words of memory which is near 9% of what I have totally
    Hi Alexey,

    This program compiles to 124 words with a 16HV540.
    Code:
    INCLUDE "modedefs.bas"
    
    RX   VAR PORTB.3
    B0   VAR BYTE
    
    SERIN RX, T2400,[85]
    This one is 154 words.
    Code:
    INCLUDE "modedefs.bas"
    
    RX   VAR PORTB.3
    B0   VAR BYTE
    
    SERIN RX, T2400,[85],B0,B0,B0,B0,B0,B0,B0,B0,B0,B0
    But this one using DEBUGIN is only 75 words.
    Code:
    DEFINE DEBUGIN_REG PORTB ' Debugin pin port 
    DEFINE DEBUGIN_BIT 3     ' Debugin pin bit 
    DEFINE DEBUGIN_MODE 0    ' Debugin mode: 0 = True, 1 = Inverted 
    DEFINE DEBUG_BAUD 2400   ' Debug baud rate 
    
    B0      VAR BYTE
    MyData  VAR BYTE
    
    DEBUGIN [WAIT(85)]       ' wait for 85
    FOR B0 = 1 TO 9
        DEBUGIN [MyDATA]     ' skip 9 bytes
    NEXT B0
    DEBUGIN [MyDATA]         ' get the desired byte
    IF only I had a 16HV540 to test it on.
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Thanks again Darrel,
    I never even thought to try DEBUGIN and I certainly did not realize how compact it is.
    Another entry in the note book.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    For the longest time I completely ignored the DEBUG/DEBUGIN statements because it just seemed too much like a Basic Stamp command.

    Then I saw Bruce using them a lot and took another look.

    They really are better than SERIN/OUT, SERIN2/OUT2.
    As long as you only need one baud rate and fixed pins ... which fits probably 90% of the usual serial programs.

    Smaller, faster ... better.
    DT

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel, with a loop of 10 cycles the last MyData will contain the desired byte saving one line instruction. (Assume something less than 75 words)

    Code:
    DEFINE DEBUGIN_REG PORTB ' Debugin pin port 
    DEFINE DEBUGIN_BIT 3     ' Debugin pin bit 
    DEFINE DEBUGIN_MODE 0    ' Debugin mode: 0 = True, 1 = Inverted 
    DEFINE DEBUG_BAUD 2400   ' Debug baud rate 
    
    B0      VAR BYTE
    MyData  VAR BYTE
    
    DEBUGIN [WAIT(85)]       ' wait for 85
    FOR B0 = 0 TO 9
        DEBUGIN [MyDATA]     ' skip 9 bytes
    NEXT B0
    'Last MyDATA will contain the desired byte
    All progress began with an idea

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aratti View Post
    Hi Darrel, with a loop of 10 cycles the last MyData will contain the desired byte saving one line instruction. (Assume something less than 75 words)
    Excellent!
    Didn't see that.

    And the compiler says ... drumroll ... 72 words.
    Aww, I thought it would save more than 3.
    DT

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    If you're not using Timer0, set it up for external clock, strap T0CKI to ground, and you have yourself a spare byte variable.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    Join Date
    Dec 2009
    Location
    Canada
    Posts
    68


    Did you find this post helpful? Yes | No

    Smile

    Wow! Gentlemen,

    Thank you for such great help. This saved me 94 of 512 words of memory, so I now can think about adding some other features. Will try how it works in reality this week and let you know.

    Another option could be going with another chip and additional driver chip to interface to a 14 Volt serial I/O line, but this makes the electrical schematic bigger, so I prefer to stay with this chip if possible.

    My understanding is that using DEBUG I will still be able to use the same pin as output before and after the DEBUG.

    Will need to learn more about the TIMER0 and how to configure to save space for one more variable because although I can live without it, it is still good to have. I have to use resonator for having precision timing, not sure it makes a difference or not.

    Thanks again!

    Thanks again

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