Re: LPC2131 SPI problem
SPI only does 8 bit and the SSP allows from 4 (?) to 16 which is
--- In lpc2000@lpc2..., "drb5599" <dbutler@c...> wrote:
> Thanks for the good info guys. I am looking at the assembly code
> for changing the SPI registers. It's just a couple simple lines:
> 165: S0SPCR = 0x0C24; // Changed to 12-bits per transfer for LCD
> 0x0000215E 2124 MOV R1,#0x24
> 0x00002160 4829 LDR R0,[PC,#0x00A4]
> 0x00002162 7001 STRB R1,[R0,#0x00]
> you can see that the assembly code just puts the 0x24 in R1, the
> upper byte is gone? Why would it do this? I am using the memory
> and register watch windows as I step thru this code. It is very
> clear to see that the upper byte is just ignored. It's like the
> compiler thinks the S0SPCR register is 8-bits instead of 16.
> That just made me look in the LPC21xx.h file where:
> #define S0SPCR (*((volatile unsigned char *) 0xE0020000))
> yes, it is defined as a char so it will only look at the first byte.
> So I changed the char to short.
> NO......it still does not work.????
> Yes, I am using a GPIO for SEL. That seems to work fine, I just
> can't change the size of the SPI buffer?
> -Dave > --- In lpc2000@lpc2..., Rob Jansen <rob@m...> wrote:
> > Dave,
> > > So I configured the SPI control register to operate in this
> > > mode.
> > >
> > > S0SPCR = 0x0C24;
> > > ...
> > > However, when I step thru my code, and look at the S0SPCR
> > > it
> > > is written with a 0x0424!!!!!!!!!!!!!
> > Strange, I tried this on my 2138 and there it all works (to say,
> > to the register works).
> > Should work on the 2131 also.
> > I wrote a small program
> > (http://www.myvoice.nl/electronics/files/io-test.zip) to read and
> > registers and memory - served me well a few times. typing "w
> > c24" will write to the memory location and read it back
> > Typing "r e0020000" will read the memory. I used this program
> > already a few times - as soon as I don't trust the hardware I
> > poking around in the chip ...
> > If writing to the register works, can you singlestep through the
> > assembly code (that's an istep in ARM AXD) or at least see the
> > code and the CPU registers?
> > > Also I am new to LCD's never programmed one before, the format
> of the
> > > data looks really strange. If anybody knows some good tricks for
> > > interfacing an LCD with a serial interface, I would be grateful.
> > I checked out the controller spec
> > (http://mxhaard.free.fr/spca50x/Doc/LCD/1621.PDF ?) and the
> > indeed is a bit strange compared to the I2C displays I am used to.
> > the command mode uses 12 bits, it you write data to the LCD you
> > switch to 14 bits mode.
> > It should however be fairly easy, CS to a GPIO pin, WR to SCK and
> > data pin of the LCD to MOSI. Configure CPOL=1 and CPHA=1 (see 213x
> > manual), LSBF=0. This gives SOSPCR = 0x0C6E to send the commands
> > after initialization switch over to 0xE6E for 14 bits to send the
> > 4 databits to a given address. Sequential datawrites should then
> be done
> > in 8 bits mode.
> > This is why you should use a GPIO pin for the CS line. Sending
> > is now like:
> > CS = Low, S0SPCR = 0x0C6E, S0SPDR = cmd, wait for SPI transfer
> > complete, CS = high.
> > Data:
> > CS = Low, S0SPCR = 0xE6E, SOSPDR = addr/data, wait for SPI tr.
> > compl, S0SPCR=0x86E, S0SPDR = data/data, wait, (more data), CS =
> > You cannot use SSEL for the CS line, the SSEL line will go
> > between datatransfers.
> > Think I still prefer an I2C display, SPI only makes sense if you
> have a
> > larger (graphical) display.
> > Good luck,
> > Rob