ShiftRegister74HC595 icon indicating copy to clipboard operation
ShiftRegister74HC595 copied to clipboard

Ability to change bit order + SPI support

Open blinkinglight opened this issue 2 years ago • 6 comments

blinkinglight avatar Mar 18 '22 14:03 blinkinglight

added SPI support. arduino uno can shift data out at up to 8mhz with almost 0 cpu cycles. also, no breaking changes ;)

blinkinglight avatar Mar 19 '22 09:03 blinkinglight

That's pretty cool, thanks for the contribution. (I'll test this before merging.)

Simsso avatar Mar 19 '22 13:03 Simsso

That's pretty cool, thanks for the contribution. (I'll test this before merging.)

ok ;) how long it could take?

blinkinglight avatar Mar 19 '22 13:03 blinkinglight

#define SHIFT_REGISTER_USES_SPI_WITH_FREQUENCY 20000000UL

#include <ShiftRegister74HC595.h>
#include <SPI.h>

#define LATCH 7

ShiftRegister74HC595<3> sr(LATCH);

void setup() {
  Serial.begin(115200);
  
  TCCR1A = 0;
  TCCR1B = 0;
  TCNT1 = 0;
  OCR1A = 10; 
  TCCR1B |= (1 << WGM12);
  TCCR1B |= (1 << CS21);
  TIMSK1 |= (1 << OCIE1A);
  sei();
}

volatile uint8_t b[3] = { 0b10010011, 0b11010011, 0b1111000 };

ISR(TIMER1_COMPA_vect)
{
  sr.setAll(b);
}

void loop() { 
  delay(1000);
}

275181554_1115425705917365_7173561953970376152_n

(signal is not clear because of long jumpwires)

blinkinglight avatar Mar 19 '22 13:03 blinkinglight

hey, any progress / problems with this PR?

blinkinglight avatar May 20 '22 08:05 blinkinglight

hey @Simsso what do you think about this? is there anything i can improve?

blinkinglight avatar Aug 22 '22 17:08 blinkinglight