LPC2132 SPI problem

Started by johnsonnenberg99 March 2, 2005

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.


An Engineer's Guide to the LPC2100 Series


--- In , "johnsonnenberg99"
<johnsonnenberg99@y...> wrote:
>
> 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.

Hi,
you must use the SSEL0 input an apply a high to this pin to enable
the SPI0 controller.

ANdreas



Hi John,

I had a similar problem with the LPC2119/29. Once I enabled the SSEL in the
pin block, it worked fine. Also - just in case - ensure the TRST,TDI,TMS,
AND TDO are tied high avia 10k. TCK tied low via 10k.

Regards

Ronnie Leighty
Principle Engineer
2802 Leslie Rd
Tampa, FL 33619
voice (813) 630-1229 ext. 111
fax (813) 630-2619 -----Original Message-----
From: johnsonnenberg99 [mailto:]
Sent: Wednesday, March 02, 2005 3:57 AM
To:
Subject: [lpc2000] LPC2132 SPI problem

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.

Yahoo! Groups Links



You are both right. One MUST enable the Slave Select pin for the
SPI to work as a Master. This is how the 210x processors work, but
it was supposed to be changed in the 2132. Per the 2132 manual,
page 157: "One the LPC2132 (unlike earlier versions), the SSEL0 pin
can be used for different functions with the SPI0 is is in Maser
Mode." WRONG!
Thank you all for your help. I've enjoyed lurking in the background
on this group.
John Sonnenberg

--- In , "haack0815" <lpc_arm@s...> wrote:
>
> --- In , "johnsonnenberg99"
> <johnsonnenberg99@y...> wrote:
> >
> > 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.
>
> Hi,
> you must use the SSEL0 input an apply a high to this pin to enable
> the SPI0 controller.
>
> ANdreas



At 09:21 PM 3/2/05 +0000, johnsonnenberg99 wrote:
>You are both right. One MUST enable the Slave Select pin for the
>SPI to work as a Master. This is how the 210x processors work, but
>it was supposed to be changed in the 2132. Per the 2132 manual,
>page 157: "One the LPC2132 (unlike earlier versions), the SSEL0 pin
>can be used for different functions with the SPI0 is is in Maser
>Mode." WRONG!

Could you add a note on that to the tips, tricks and traps on
http://www.open-research.org.uk/ARMuC/ ? I have a feeling this is going to
become a FAQ.

Robert

" 'Freedom' has no meaning of itself. There are always restrictions,
be they legal, genetic, or physical. If you don't believe me, try to
chew a radio signal. "

Kelvin Throop, III



--- In , "johnsonnenberg99"
<johnsonnenberg99@y...> wrote:
>
> You are both right. One MUST enable the Slave Select pin for the
> SPI to work as a Master. This is how the 210x processors work, but
> it was supposed to be changed in the 2132. Per the 2132 manual,
> page 157: "One the LPC2132 (unlike earlier versions), the SSEL0 pin
> can be used for different functions with the SPI0 is is in Maser
> Mode." WRONG!
> Thank you all for your help. I've enjoyed lurking in the background
> on this group.
> John Sonnenberg
>
> --- In , "haack0815" <lpc_arm@s...> wrote:
> >
> > --- In , "johnsonnenberg99"
> > <johnsonnenberg99@y...> wrote:
> > >
> > > 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.
> >
> > Hi,
> > you must use the SSEL0 input an apply a high to this pin to enable
> > the SPI0 controller.
> >
> > ANdreas

Sorry for the wrong info, but the older UM of the 2132/38 has an error
and tell that you must pull high the SSEL0 pin and the new UM tells
that you can use this pin as gpio.

Andreas




Do I understand you to be saying that the manual is wrong, and even
on LPC213x you cannot use SSEL as GPIO when SPI is in Master mode?

Did you actually test this?
Has anyone else tested this? --- In , "johnsonnenberg99"
<johnsonnenberg99@y...> wrote:
>
> You are both right. One MUST enable the Slave Select pin for the
> SPI to work as a Master. This is how the 210x processors work, but
> it was supposed to be changed in the 2132. Per the 2132 manual,
> page 157: "One the LPC2132 (unlike earlier versions), the SSEL0 pin
> can be used for different functions with the SPI0 is is in Maser
> Mode." WRONG!
> Thank you all for your help. I've enjoyed lurking in the background
> on this group.
> John Sonnenberg





Yes, did actally do the test. After 5 hours of trying everything, I
took the group's advise, enabled the the SSEL0 pin, put a 10K pull-
up on it, and everything worked fine.
John
--- In , "lp2000c" <lp2000c@e...> wrote:
>
> Do I understand you to be saying that the manual is wrong, and
even
> on LPC213x you cannot use SSEL as GPIO when SPI is in Master mode?
>
> Did you actually test this?
> Has anyone else tested this? > --- In , "johnsonnenberg99"
> <johnsonnenberg99@y...> wrote:
> >
> > You are both right. One MUST enable the Slave Select pin for
the
> > SPI to work as a Master. This is how the 210x processors work,
but
> > it was supposed to be changed in the 2132. Per the 2132 manual,
> > page 157: "One the LPC2132 (unlike earlier versions), the SSEL0
pin
> > can be used for different functions with the SPI0 is is in Maser
> > Mode." WRONG!
> > Thank you all for your help. I've enjoyed lurking in the
background
> > on this group.
> > John Sonnenberg