How do you change the speed of the spi clock?

I guess my other post was too long and general so I’ll try this. I think the clock rate for SPI is too fast for my device so I would like to slow it down to test.

  1. It seems spiOut() is a library function, where is the library so I can see what it does.
  2. Another way is to use the hardware spi, this was demonstrated in a tutorial but I don’t know where the info on the registers you need to set is located.

Any help is appreciated. Thanks.

Section 18.5 of the datasheet (page 169) explains the SPI registers. Bits 0 and 1 (SPR0 and SPR1) of the SPI control register SPCR determine the SPI clock frequency as a function of the oscillator clock frequency. Bit 0 (SPI2X) of the SPI status register SPSR will double the SPI clock frequency if set. Together these three bits allow you to select from seven different SPI clock frequencies between Fosc/2 (8 MHz) and Fosc/128 (125 kHz).

  • Ben

Thanks Ben, I’ll see if that fixes/changes my problem.