Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

SPI Issue

2005-07-15 by slavidian

Hello,

I have created a simple driver to read the status register of an SPI 
EEPROM using the LPC2106 as master.  I posted the short code below.  
MOSI and SCK signals appear on the scope, but nothing comes out of 
the slave MISO port on the EEPROM (Status Register contents should be 
seen).  SSEL is pulled up with a 10k resistor and is attached to 
nothing.  Instead GPIO simulates the chip select as recommended on 
this forum (not in the errata).  I have tried different EEPROMs and 
configured SPCR accordingly, so this is not the problem.  Either the 
signals coming from the lpc2106 are garbage or I am missing something.

Please help!
      


#define SPIF_DONE 0x80

void main (void)
{  
  char i;

  VPBDIV=0x1;                 //pclk = cclk (14.7456 mhz)

  PINSEL0 = 0x00005500;	      //Enable SPI pins  
  IODIR   = 0x00000400;	      //Configure P0.10 as output
  IOSET   = 0x00000400;       //P0.10 high (substitute for SSEL) 
  SPCCR	  = 0x000000FE;	      //divider = 254; must be multiple of 2
  SPCR    = 0x00000020;	      //SPI Master; Mode 0,0 (chpa, cpol)
 
  IOCLR   = 0x00000400;	      //Enable Chipselect
  asm("NOP");                 //Give GPIO time
  SPDR 	  = 0x00000005;       //Send ReadStatusRegister command
  while(!(SPSR & SPIF_DONE)); //Poll until send/recv complete
  IOSET   = 0x00000400;       //Disable Chipselect
  i       = SPDR;             //Read the Stat Reg transfered in
  Write(i);                   //Display Stat Reg contents
}

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.