How can I speed this code up? SHIFTOUT is slowing it down and I need a faster way.


Closed Thread
Results 1 to 30 of 30

Hybrid View

  1. #1
    Join Date
    Mar 2010
    Location
    Minnesota, USA
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Nope the same.

    Quote Originally Posted by Gusse View Post
    Code:
    <code><font color="#000000">    dpin = Dat.0(7) : clk = 1 : clk = 0
        dpin = Dat.0(6) : clk = 1 : clk = 0
        dpin = Dat.0(5) : clk = 1 : clk = 0
        dpin = Dat.0(4) : clk = 1 : clk = 0
        dpin = Dat.0(3) : clk = 1 : clk = 0
        dpin = Dat.0(2) : clk = 1 : clk = 0
        dpin = Dat.0(1) : clk = 1 : clk = 0
        dpin = Dat.0(0) : clk = 1 : clk = 0
    </code>

    BR,
    -Gusse-
    Nope the same.

    20 MHz Clock will still be too slow with SHIFTOUT.

    I am assuming your code has something to do with accessing per bit in the word sized Dat variable. So if I wanted to access the 11th bit I would do this Dat.1(2) right?

    Would anyone have a faster way in Assembly I could do this?

    Also Does anyone know how many clock pulses SHIFTOUT uses?
    Last edited by wolwil; - 8th May 2010 at 17:16.

  2. #2
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by wolwil View Post
    Nope the same.

    20 MHz Clock will still be too slow with SHIFTOUT.
    In your 1st post you are saying that you are running @16MHz. 20MHz is 25% faster than you present system.

    Quote Originally Posted by wolwil View Post
    I am assuming your code has something to do with accessing per bit in the word sized Dat variable. So if I wanted to access the 11th bit I would do this Dat.1(2) right?

    Would anyone have a faster way in Assembly I could do this?

    Also Does anyone know how many clock pulses SHIFTOUT uses?
    Code does exactly the same as SHIFTOUT but just little bit faster.
    If this didn't help then SHIFTOUT is not the bottleneck.
    Keep looking other solutions.

    11th bit would be Dat.0(10).
    Example below (remember MSBFIRST).
    Code:
    <code><font color="#000000">    Dat     VAR BYTE [2]
    
        dpin = Dat.0(7) : clk = 1 : clk = 0
        dpin = Dat.0(6) : clk = 1 : clk = 0
        dpin = Dat.0(5) : clk = 1 : clk = 0
        dpin = Dat.0(4) : clk = 1 : clk = 0
        dpin = Dat.0(3) : clk = 1 : clk = 0
        dpin = Dat.0(2) : clk = 1 : clk = 0
        dpin = Dat.0(1) : clk = 1 : clk = 0
        dpin = Dat.0(0) : clk = 1 : clk = 0
        
        dpin = Dat.0(15) : clk = 1 : clk = 0
        dpin = Dat.0(14) : clk = 1 : clk = 0
        dpin = Dat.0(13) : clk = 1 : clk = 0
        dpin = Dat.0(12) : clk = 1 : clk = 0
        dpin = Dat.0(11) : clk = 1 : clk = 0
        dpin = Dat.0(10) : clk = 1 : clk = 0  <font color="#000080"><i>'&lt;- 11th
        </i></font>dpin = Dat.0(9)  : clk = 1 : clk = 0
        dpin = Dat.0(8)  : clk = 1 : clk = 0
    
    </code>
    EDIT: If you or anybody know faster SHIFTOUT workaround with PBP, I would be interested.

    BR,
    -Gusse-
    Last edited by Gusse; - 8th May 2010 at 18:16. Reason: EDIT

  3. #3
    Join Date
    Mar 2010
    Location
    Minnesota, USA
    Posts
    41


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Gusse View Post
    Code does exactly the same as SHIFTOUT but just little bit faster.
    If this didn't help then SHIFTOUT is not the bottleneck.
    Keep looking other solutions.

    BR,
    -Gusse-
    Well I have come to the realization that it is not the SHIFTOUT slowing me down but the pulsing of PORTA.3 for 4096 times. I need to get this to be faster.

    For better help on this I am going to add on to an older post that deals with the chip I am using so I don't create multiples on here.

    Thanks everyone for your help.

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


    Did you find this post helpful? Yes | No

    Default

    Use a 16 bit counter in assembly to count to 0FFF.
    In that loop, use the instruction -

    btg LATA.3

    You can't get much quicker than that.

    I haven't counted exactly, but it looks to be under 14 cycles. At 40Mhz, that is
    1.4uSEC = 714 Khz.
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Default

    I should have stated that it is 1.4uSec per CYCLE. So 4096 cycles would take 5.8 milliseconds.
    Charles Linquist

  6. #6
    Join Date
    Mar 2010
    Location
    Minnesota, USA
    Posts
    41


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles Linquis View Post
    Use a 16 bit counter in assembly to count to 0FFF.
    In that loop, use the instruction -

    btg LATA.3

    You can't get much quicker than that.

    I haven't counted exactly, but it looks to be under 14 cycles. At 40Mhz, that is
    1.4uSEC = 714 Khz.
    so do I just replace this:
    Code:
    	FOR C3 = 0 TO 4095
        		PORTA = %00001000
        		PORTA = %00000000
    	NEXT
    with this:
    Code:
    FOR C3 = 0 TO 4095
         btg LATA.3
    NEXT
    I do not know assembly at all thats why I went with PBP and keep in mind I am using a 16MHz Clock but I will be switching it up to a 20MHz
    Last edited by wolwil; - 9th May 2010 at 00:19.

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


    Did you find this post helpful? Yes | No

    Default

    No, it will take a bit more than that.

    I would have posted something more complete, but I don't have access to my development board until Monday. When I get to my board, I'll be able to send you something that has been tested.
    Charles Linquist

  8. #8
    Join Date
    Mar 2010
    Location
    Minnesota, USA
    Posts
    41


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles Linquis View Post
    No, it will take a bit more than that.

    I would have posted something more complete, but I don't have access to my development board until Monday. When I get to my board, I'll be able to send you something that has been tested.
    That would be awesome! Thanks

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