This is an area that can use some optimization, I bit banged the 96 bits I needed on the atmega168. I think it was actually faster than the spi hardware, and I could use any GPIO pin i wanted.
On a more modern processor using the SPI HW with DMA or fifo would almost certainly be better. I did it in assembler. < 200 cycles to clock out the 96 bits. Atmega specific of course > *;--- shift out display buffer* > *;--* > *shift_out: _init_z _disp_buff ; point to primary buffer * > * ldi ii,DISP_BUFF_SIZE ; how many bytes to clock out* > > *shift_out_lpt: ldi temp2,8 ; bit counter, 8 bits in a byte * > * ld temp,z+ ; get the byte of data* > > *shift_out_lp: cbi DOUT_PORT,DOUT ; assume zero bit * > * rol temp ; move data bit to carry* > > * brcc pc + 2* > * sbi DOUT_PORT,DOUT * > > * cbi clk_port,CLK* > * sbi clk_port,CLK ; blip clock line * > > * dec temp2 ; done yet?* > * brne shift_out_lp * > > * dec ii* > * brne shift_out_lpt * > > * // _LATCH_DATA * > * sbi latch_port,latch** cbi latch_port,latch* > * ret* carl -------------------------------------------------------- Henry Carl Ott N2RVQ hcarl...@gmail.com On Mon, Oct 8, 2018 at 2:31 PM SWISSNIXIE - Jonathan F. <jfrech...@gmail.com> wrote: > I'm using HV5122/HV5222 in all my applications, and im pretty sure most of > the microchip HV series are identical only differ in voltage and some > protocol types. > > They can be driven at 5V, but 'm using a Level Shifter (CD4504) to shift > from 5 to 12V > > How ever, one major issue with these IC's is that if you use arduino, > flicker can occur depending on your arduino and code. > If you translate the "digitalWrite()" to assembler code, you get about 55 > assembler commands. > > To shift out 64bit of data, you need around 130 "digitalWrite()"'s if you > do it sloppy, if you check for following 0 or 1 you can save some, but lets > figure you need 130. > > 130 digitalWrite() * 55 Assembler commands = 7150 commands. > If your Arduino runs at 16Mhz one command takes about 62ns > If your Arduino runs at 8Mhz one command takes about 124ns > > To run 7150 commands, it would take 443us for 16Mhz and 886us for 8Mhz. > And this calculation does not include delays in execution that are created > by interrupts! So in some case you will se flickering in the digits! It > happened to me alof of times, so i created the follwing function that can > be way faster than digital write: > > https://github.com/sgtJohnny/sunix/blob/master/sunix.ino > > #define DATA PD5 //define Dataline >> #define OE 6 //define latch pin >> #define CLK PD7 //define clockline >> #define thePort PORTD //define Hardware port where Shift-Registers are >> connected >> > > >> void setOutputs(unsigned long val_one, unsigned long val_two) { //Function >> to shift out 2 x 32bit fast enough to prevent flicker! >> > // ------------WARNING!-------------------- >> // This functions operates directly on ports, not via digitalWrite() >> // because digitalWrite() would be to slow, and display would flicker >> // if different pins are used, you maybe hav to change the variable >> "thePort" >> // to the matching I/O port letter of the controller! >> >> digitalWrite(OE, LOW); //Disable Outputs to prevent flicker >> >> //Send first 32-bit variable value >> >> for (int i = 0; i < 32; i++) { >> thePort &= ~_BV(DATA); //Data LOW >> if ( bitRead(val_one, i) == 1) { >> thePort |= _BV(DATA); //Data HIGH >> } >> thePort |= _BV(CLK); //CLK HIGH >> thePort &= ~_BV(CLK); //CLK LOW >> } >> >> //Send second 32-bit variable value >> for (int i = 0; i < 32; i++) { >> thePort &= ~_BV(DATA); //Data LOW >> if ( bitRead(val_two, i) == 1) { >> thePort |= _BV(DATA); //Data HIGH >> } >> thePort |= _BV(CLK); //CLK HIGH >> thePort &= ~_BV(CLK); //CLK LOW >> } >> digitalWrite(OE, HIGH); //Enable Outputs >> >> } >> > > If one would use a Arduino Mega or STM32 you could use the second SPI Port > to shift out to the Registers > > >> -- > You received this message because you are subscribed to the Google Groups > "neonixie-l" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to neonixie-l+unsubscr...@googlegroups.com. > To post to this group, send email to neonixie-l@googlegroups.com. > To view this discussion on the web, visit > https://groups.google.com/d/msgid/neonixie-l/7a03013b-823e-4e95-a8d3-792dac750c1c%40googlegroups.com > <https://groups.google.com/d/msgid/neonixie-l/7a03013b-823e-4e95-a8d3-792dac750c1c%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "neonixie-l" group. To unsubscribe from this group and stop receiving emails from it, send an email to neonixie-l+unsubscr...@googlegroups.com. To post to this group, send an email to neonixie-l@googlegroups.com. To view this discussion on the web, visit https://groups.google.com/d/msgid/neonixie-l/CAP_hP_QDKk%3DKqisYRgEuyMm44%3DmeBvYs-_aW739GCMH5KE%2Bb6g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.