Yahoo Groups archive

Lpc2000

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

Message

LPC2132 SPI problem

2005-03-02 by johnsonnenberg99

I just can't get the SPI port on the 2132 to work (master mode).  
Any help would be MUCH appreciated!
I've setup the pin connect block per the manual, enable the SPI port 
in the PCONP register, programmed the SPI registers, and then try to 
send a byte.  It appears to send in software, and the SPIF bit get 
set, but nothing comes out the MOSI pin or the SCK pin (both stuck 
low).  I don't think I have a short on the PCB.

Here's the main sections of code 


//********************************************
//********************************************
void OpenMasterSPI0(void)
{
  PCONP_bit.PCSPI0 = 1;               // enable the SPI hardware
  PINSEL0 = PINSEL0 & 0xFFFF00FF;     // set the pin-select 
regisgters to enable the SPI pins
  PINSEL0 = PINSEL0 | 0x00001500;     // Enable SPI pins, but do not 
use the Slave Select Pin.  It is GPIO.
  // set the pins to SPI
  SPCCR0 = 128;                       // clk for the SPI clock.  
  SPCR0 = 0x20 ;                      // master mode, active high 
clock, no IRQ
}


//*****************************************************
// Write a byte to the SPI, and also read one in. 
//*****************************************************
char WriteReadSPI0(char b)
{
  int i=0;
  SPDR0 = b;                // this write starts the spi transmission
  i=0;
  while( i == 0 )
        i = (SPSR0 & 0xff);   // wait till we are done. 
  return SPDR0;
}

Thanks in advance for any ideas.

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.