EmbeddedRelated.com
Forums

Problem initating display with spi, at91sam7s

Started by yeayeah85 June 6, 2009
Hi all!

I have been trying to get this display to work whole week and I'm near insanity :(

I have an OLED, dd-160128fc-2a. It is controlled via SPI. Its minimum clock cycle is 60nS (= 16.66MHz). The display is all black and nothing seems to get threw..

display: http://www.techdesign.be/shop/datasheets/dd-160128fc-2a.pdf
controller: http://www.techdesign.be/shop/datasheets/SEPS525%5B1%5D.pdf

I can't start it and I'm not 100% sure I implemented the spi correct, could you please see any errors?

To setup the display I need to send 8-bit data like this:
...

//Send INDEX
while ((pSPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0);
PIO_Clear(pinOled_RS);//Pull down RS
Wait(1); //1ms
pSPI->SPI_TDR = (index & 0xFF) | SPI_PCS(1); //1==npcs
while ((pSPI->SPI_SR & AT91C_SPI_TDRE) == 0);
while ((pSPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0);
PIO_Set(pinOled_RS);//Pull up RS

Wait(3); //3 ms

//Send CONTROL
while ((pSPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0)
pSPI->SPI_TDR = (control & 0xFF) | SPI_PCS(1); //1==npcs
while ((pSPI->SPI_SR & AT91C_SPI_TDRE) == 0);
while ((pSPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0);

...

Do you think i need to call the wait-functions to be sure that the pinOled_RS has the right value when sending index or control?

SPI is configured this way:

//CONFIGURE MODE REGISTER
unsigned int config = AT91C_SPI_MSTR | AT91C_SPI_PS_VARIABLE | AT91C_SPI_MODFDIS | (AT91C_SPI_PCS & (0xF << 16)) | (AT91C_SPI_DLYBCS & (0x00 << 24));

SPI_Configure(pSPI,config);

//CONFIGURE ACCELEROMETER
unsigned int configCSR0 = AT91C_SPI_CPOL |
AT91C_SPI_BITS_16 |
(AT91C_SPI_SCBR & (0x10 << 8)) |
(AT91C_SPI_DLYBS & (0x00 << 16)) ;
SPI_ConfigureNPCS(pSPI,0,configCSR0);

//CONFIGURE OLED
unsigned int configCSR1 = AT91C_SPI_NCPHA | AT91C_SPI_BITS_8 | (AT91C_SPI_SCBR & (0x40 << 8)) | (AT91C_SPI_DLYBS & (0x06 << 16)) ;
SPI_ConfigureNPCS(pSPI,1,configCSR1);

//ENABLE SPI
SPI_Enable(pSPI);

...
The accelerometer works like it should..

Cheers!

On Sat, 06 Jun 2009 16:44:25 -0000
"yeayeah85" wrote:
> I can't start it and I'm not 100% sure I implemented the spi correct,
> could you please see any errors?

I'm just grabbing a few minutes to check my email this morning, but the
thing I've found most useful when trying to debug this sort of stuff is
to set up the device to just be sending the SPI stuff over and over and
hook an oscilloscope up. If you use another pin as the trigger you
should be able to read the bits on the wire, and this will tell you if
you've got the port initialized correctly, at least for output, because
you'll be able to see what speed you're sending the data at and (with
the external pin) what the bits are.

Dan
IT IS WORKING!!

Yeahh, it's a damn nice feeling when the display shines up! :)

I needed to set the CSAAT-bit to keep the CS low when writing 3 8-bit RGB values..

Thanks for your help Dan..