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

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

    I think what is slowing this down is the SHIFTOUT.

    I am running a 16f88 @ 16MHz and I need to know the fastest way to get through this loop:

    Code:
    LOOP:
    	FOR DATA = 4095 to 0 step -1
        		GOSUB SUB1
    	    	GOSUB SUB2
    	NEXT
    	FOR DATA = 0 to 4095 step 1
        		GOSUB SUB1
        		GOSUB SUB2
    	NEXT
    GOTO LOOP
    
    SUB1:
    	FOR C1 = 0 TO 15
        		shiftout dpin,clk,1,[DATA]
    	NEXT
        	PORTB = %00100000 
        	PORTB = %00000000  
    RETURN
    
    SUB2:
    	PORTB = %00000100 
    	PORTB = %00000000 
    	FOR C3 = 0 TO 4095
        		PORTA = %00001000
        		PORTA = %00000000
    	NEXT
    RETURN

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


    Did you find this post helpful? Yes | No

    Default

    131,072 SHIFTOUTs in that loop and it is shifting the same value 15 times, getting another value and shifting that 15 times, again ,again.... That will tale some time.

    Unless I am looking at it cross eyed...

    Is the above really what you want to do?
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    131,072 SHIFTOUTs in that loop and it is shifting the same value 15 times, getting another value and shifting that 15 times, again ,again.... That will tale some time.

    Unless I am looking at it cross eyed...

    Is the above really what you want to do?
    Yes but not 15 times 16 times and really its not all that bad if I would be able to have it shifting say at 1MHz or more

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


    Did you find this post helpful? Yes | No

    Default

    I wonder if SHIFTING all 16 values at once would be faster than looping? Darn zeros
    Code:
    shiftout dpin,clk,1,[DATA,DATA,DATA,DATA,DATA,...]
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    I wonder if SHIFTING all 16 values at once would be faster than looping? Darn zeros
    Code:
    shiftout dpin,clk,1,[DATA,DATA,DATA,DATA,DATA,...]
    I dunno let me try it...
    Last edited by wolwil; - 8th May 2010 at 06:54.

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


    Did you find this post helpful? Yes | No

    Default

    Nope The Same

    The part that is slow is going from SUB1 to SUB2 not the looping through them 4096 times

    I just tried taking out the GOSUB's and still the same thing

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