# Arduino SPI Clock Speed Configuration

I am trying to communicate with a Nokia 1202 LCD with my Arduino using SPI.

The LCD using the STE2007 Controller. As per the datasheet here @ page 12, you find that the min time for SCLK is 250ns => 4MHz and no maximum value listed. So what i understand is that this driver can communicate using SPI with SCLK being max. of 4MHz.

Since my arduino board is running at 16MHz, and I will be using the 'spi' library this is what I think i should do:

1. set bits SPR0 and SPR1 in the SPCR register to set the spi clock speed @ 4MHz
2. do spi.begin()
3. execute spi commands as normal

Is this correct ?

Something like ...

void setup()
{
pinMode(SPI_SS, OUTPUT);
pinMode(SPI_DC_SEL, OUTPUT);
SPI.begin();
SPI.setBitOrder(MSBFIRST);
//set spi register to set SCLK @ 4Mhz
//SPI2X = SPR1 = SPR0 = 0
SPCR &= ~(1<<SPR1);
SPCR &= ~(1<<SPR0);
SPSR &= ~(1<<SPIX2);
}

• why don't you try that and see if it works, e.g. try to read a register from the LCD, and come back here if/when you have a problem. – mux Oct 4 '12 at 6:12

  SPI.setDataMode(SPI_MODE3);

Also, SPI.begin sets all the pin modes for you, so no need to do that.