Faster SHIFTOUT without dedicated hardware, possible?


Results 1 to 20 of 20

Threaded View

  1. #2
    Join Date
    Aug 2011
    Posts
    453


    2 out of 2 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: Faster SHIFTOUT without dedicated hardware, possible?

    Sure.

    Here's some code that would shift out a byte without using asm or anything special... should be much faster than SHIFTOUT since it's format is dedicated and loop is unrolled. Just set WREG to the value to shift out and call SHOUT.

    Code:
    SHCLK var PORTB.0
    SHDAT var PORTB.1
    
    ; init pins to output low
    low SHCLK
    low SHDAT
    
    ; send $55
    WREG = $55
    call SHOUT
    
    ; send $AA
    WREG = $AA
    call SHOUT
    
    
    ; SHOUT
    ; shift out 8 bits of data, LSB to MSB
    ; data clocked on rising edge of SHCLK
    ; WREG = data to send
    SHOUT:
    SHDAT = 0
    if WREG.0 then
      SHDAT = 1
    endif
    SHCLK = 1
    SHCLK = 0
    
    SHDAT = 0
    if WREG.1 then
      SHDAT = 1
    endif
    SHCLK = 1
    SHCLK = 0
    
    SHDAT = 0
    if WREG.2 then
      SHDAT = 1
    endif
    SHCLK = 1
    SHCLK = 0
    
    SHDAT = 0
    if WREG.3 then
      SHDAT = 1
    endif
    SHCLK = 1
    SHCLK = 0
    
    SHDAT = 0
    if WREG.4 then
      SHDAT = 1
    endif
    SHCLK = 1
    SHCLK = 0
    
    SHDAT = 0
    if WREG.5 then
      SHDAT = 1
    endif
    SHCLK = 1
    SHCLK = 0
    
    SHDAT = 0
    if WREG.6 then
      SHDAT = 1
    endif
    SHCLK = 1
    SHCLK = 0
    
    SHDAT = 0
    if WREG.7 then
      SHDAT = 1
    endif
    SHCLK = 1
    SHCLK = 0
    
    return
    That would be the equivalent of
    SHIFTOUT SHDAT, SHCLK, LSBFIRST, [bval/8]
    Last edited by tumbleweed; - 27th July 2022 at 12:31.

Similar Threads

  1. Replies: 29
    Last Post: - 20th May 2010, 03:47
  2. Is there a faster way to compare?
    By RussMartin in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 8th February 2010, 19:48
  3. Dedicated LCD Controller question
    By chuckles in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th February 2006, 14:44
  4. Is there a faster/better way of doing this?
    By Mad_Labs in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th October 2005, 11:01

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