hi all
maybe a silly question but i m try to understand how clocks works im using TPIC6B595N shift registers and using and would like to know whats the diference on the clock settings and whats best option on SPI.setClockDivider (SPI_CLOCK_DIV2);SPI_CLOCK_DIV4, or SPI_CLOCK_DIV8, if any explanation for arduino uno .
if possible give me some information or direct me to where to find information about it to understand better
I normally just use the default settings, which results in 4 MHz clock.
If I need it really fast, 8 MHz, I use the Div2 setting.
Did you look at the SPI library page?
To use it:
#include <SPI.h> // connect SCK to SRCLK, MOSI to Serial In
// connect MSCLR to +5, and OE (G/) to Gnd.
byte ssPin = 10; // connect to RCLK
myData1 = 0xAA; // test byte, 0b10101010
myData2 = 0x55; // test byte, 0b01010101
void setup(){
pinMode (ssPIN, OUTPUT);
SPI.begin();
// add clock change next if using it
}
void loop(){
digitalWrite (ssPin, LOW);
SPI.transfer(myData1);
digitalWrite (ssPin, HIGH); // outputs change on this rising edge
delay (2000);
digitalWrite (ssPin, LOW);
SPI.transfer(myData2);
digitalWrite (ssPin, HIGH); // outputs change on this rising edge
delay (2000);
}
TPIC6B595 only sinks current. Test with an LED/resistor wired in series thusly: 5V to anode, cathode to resistor, resistor to output pin.
Or, 5V to resistor, resistor to anode, cathode to output pin.
thanks for fast reply
So basikly what the SPI.setClockDivider is doing is setting how fast the clock will send my data
SPI_CLOCK_DIV2 will work 4 MHZ
SPI_CLOCK_DIV4 at 8 MHZ
SPI_CLOCK_DIV8 at 16 Mhz(max that arduino uno handles)
does this also mean in some cases migh work better on lower speed and other cases better in faster speeds in case of some bugs?
Backwards:
SPI_CLOCK_DIV2 will work 8 MHZ - fastest that 16 MHz processor can create
SPI_CLOCK_DIV4 at 4 MHZ (default speed)
SPI_CLOCK_DIV8 at 2 Mhz
Be sure to use a 0.1uF ceramic cap from each shift register's Vss pin to Gnd.
does this also mean in some cases migh work better on lower speed and other cases better in faster speeds in case of some bugs?
No - not working at faster speeds might be an indication of hardware wiring issues.
The TPIC6B595 is plenty capable of accepting data with 8 MHz. I've connected up 45 of them even, and used other software means to blast out 45 bytes in about 47microseconds.
(8 bits need 17 or 18 clocks to be shifted out).
This board I offer for example has a '328P for Arduino functionality and 12 TPIC6B595 shift registers for 96 channels of high current output.
http://www.crossroadsfencing.com/BobuinoRev17/