Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

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);
}
share|improve this question
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

1 Answer

up vote 0 down vote accepted

You can set the SPI speed (and many other things!) using the Arduino SPI library without specifying any register values. You already did it with MSBFIRST. Like so:

  SPI.setDataMode(SPI_MODE3);
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(SPI_CLOCK_DIV4); // 16/4 MHz
  SPI.begin(); 

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

share|improve this answer
thanks! should have checked the arduino SPI library documentation before asking the question. – Ankit Oct 4 '12 at 6:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.