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

|
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.
Bookmarks