Arduino Forum

Forum 2005-2010 (read only) => Software => Interfacing => Topic started by: jeffonfire on Sep 03, 2009, 01:50 am

Title: 9 bit SPI
Post by: jeffonfire on Sep 03, 2009, 01:50 am
I have no experience with SPI and am trying to use it to connect to a LCD, how do you set up the sck pin to provide the desired clock speed. I want to run it at 6 MHz.

Also are there any SPI tutorials better than the digital pot and spi eeprom tuts?
Title: Re: 9 bit SPI
Post by: dareheaven on Sep 09, 2009, 06:55 pm
wow some technical stuff, well to me it is
:S
Title: Re: 9 bit SPI
Post by: Grumpy_Mike on Sep 09, 2009, 08:34 pm
Quote
I want to run it at 6 MHz.


Sorry you can't. If you look at the data sheet you will see that the clock frequency is derived from the crystal divided by either 2, 4, 8, 16, 32, 64, or 128.
As the arduino has a 16MHz clock you can't get 6MHz. Closest you could get is if you select a divider value of divide by 4, this will give you 4MHz.

This is controlled by the two least significant bits of the SPCR register and the least significant bit of the SPSR register. See the processor data sheet for more details.