Hello again and thank you for the pointer about how to include the code.
I have extracted the relevant points from the main program to illustrate my method.
I have declared the 64 bit variable using uint64_t.
Everything about the my previous attempts has worked perfectly - as long as I stuck within the constraints of using only 32 bits and shifting them to the right in order to perform groups of 8 bit transfers.
Am I pursuing something which is achievable or would I be better reverting to using on 32 bits?
- Richard
#include <SPI.h>
const byte LEpin = 12;
uint64_t l ; //the new store for 64 bits for the shift registers
void setup() {
// put your setup code here, to run once:
// set up SPI
SPI.begin();
SPI.setFrequency(100000);
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE1);
//set outputs for SPI
pinMode(LEpin, OUTPUT);
}
void loop() {
// This for loop just sets l to 0, then sets bits and calls the spi transfer
// change the 32 to 24, 16, 8 or 0 to work on different sets of bits
for (int jloop=0; jloop<8; jloop++){
l=0;
bitSet(l,jloop+32);
spiTX();
nonBlock(3000);
}
}
void spiTX(){
//send L out
//SPI transfer code
// perhaps split l into two parts, the lower part
digitalWrite(LEpin, LOW);
// SPI.transfer((l >> 56) & 0xff);
// SPI.transfer((l >> 48) & 0xff);
// SPI.transfer((l >> 40) & 0xff);
// SPI.transfer((l >> 32) & 0xff);
// SPI.transfer((l >> 24) & 0xff);
// SPI.transfer((l >> 16) & 0xff);
// SPI.transfer((l >> 8) & 0xff);
// SPI.transfer(l & 0xff);
SPI.transfer(&l,32);
digitalWrite(LEpin, HIGH);
}
//This is a non-blocking 'delay' - use instead of 'delay' to avoid ESP8266 WDT resets
void nonBlock(unsigned long delay_time)
{
unsigned long time_now = millis();
while (millis() < time_now + delay_time) {
yield();
ESP.wdtFeed();
//waiting!
}
}