Fast bitshifting needed!!!

olegb

New Member
Dear Pickaxes,

I ‘m looking for the most efficient, (fast!) shift register algorithm for my nixie clock project.
I ‘m using 28X1 and HV5812 20-bit shift register to multiplex 6 nixies.
I need to shift 16 bits within 2 ms, 125us/bithift to avoid nixies flickering.
The best what I've got so far is 1.2 ms/bitshift which is 10 times slower then needed.
And this is with 16MHz AXE28X1 clocking! Most likely part of the problem is just my clumsy test program (below). However I‘ve done similar (C program) testing with AVR Atmega 8 (8 MHz) and 125us/bit shift speed is no problem there. Is it possible to achieve the same results with AXE28X1?
Any help, advise/suggestions would be highly appreciated,

Here is my test program:

symbol dgt1=b1
symbol dgt2=b2
symbol outbyte=b3
symbol bitcount=b4
symbol temp=b5
setfreq em16


main:

dgt1=80
for dgt2=0 to 5 '6 bytes buffer, 80-85'
peek dgt1,outbyte 'shift buffer'
for bitcount=0 to 7
temp=outbyte & 1 'bit prep'
if temp=1 then outhi
low 3 'HV5812 data in
goto clockout
outhi: high 3

clockout:

pulsout 1,1 'HV5812 shift clock
outbyte = outbyte/2 'next bit prep
next bitcount
dgt1=dgt1+1 'next byte prep
bit0=bit0^1
if bit0=0 then '16 bits shift complete flag
pulsout 2,1 'HV5812 latch control
end if
next dgt2

goto main


Thank you for your help!
olegb
 

hippy

Technical Support
Staff member
The first trick would be to unroll your loops and get rid of any slow operations such as multiply or divides. Make your 'outbyte' as b0 then you get instant access to its individual bits, so ..

- b0 = byte to churn out
-
- outpin3 = bit0 : pulsout 1,1
- outpin3 = bit1 : pulsout 1,1
- :
- outpin3 = bit6 : pulsout 1,1
- outpin3 = bit7 : pulsout 1,1

If you want maximum speed, look at the high-speed SPI commands. They will be blindingly fast :)
 

olegb

New Member
Hippy, thank you very much!
will try SPI program tonight.
any SPI applications hints/tricks for AXE28X1?
Thanks again!

olegb
 

olegb

New Member
SUCCESS!!!
I tested SPI loop tonight, and got 30us/bit shift speed within 16 bit shifting SPI loop at 16 MHz. Both test programs (below) needs 1.6 ms to complete the loop.
This gives me nice 0.4 ms anti-flickering margin and I ‘m happy man now!
Thanks again, Hippy!
olegb

Test 1:

symbol dgt1=b2
symbol dgt2=b3
symbol outbyte=w2
symbol LSB=b4
symbol MSB=b5
setfreq em16

main:

dgt1=80 '6 bytes buffer, 80-85'
A1: peek dgt1,LSB
dgt1=dgt1+1
peek dgt1,MSB
spiout 1,3,0,(outbyte/16) 'shift buffer'
dgt1=dgt1+1 'next byte prep
pulsout 2,1
if dgt1=<85 then A1
goto main

Test2:

symbol dgt1=b2
symbol dgt2=b3
symbol outbyte=w2
symbol LSB=b4
symbol MSB=b5
setfreq em16


main:

dgt1=80
for dgt2=0 to 5 '6 bytes buffer, 80-85'
peek dgt1,LSB
dgt1=dgt1+1
peek dgt1,MSB
spiout 1,3,0,(outbyte/16) 'shift buffer'
dgt1=dgt1+1 'next byte prep
pulsout 2,1 'HV5812 latch control
next dgt2

goto main
 
Top