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 register,
> it
> is written with a 0x0424!!!!!!!!!!!!!
Strange, I tried this on my 2138 and there it all works (to say, writing
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 write
registers and memory - served me well a few times. typing "w e0020000
c24" will write to the memory location and read it back afterwards.
Typing "r e0020000" will read the memory. I used this program myself
already a few times - as soon as I don't trust the hardware I start
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 assembly
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 interface
indeed is a bit strange compared to the I2C displays I am used to. Only
the command mode uses 12 bits, it you write data to the LCD you should
switch to 14 bits mode.
It should however be fairly easy, CS to a GPIO pin, WR to SCK and the
data pin of the LCD to MOSI. Configure CPOL=1 and CPHA=1 (see 213x user
manual), LSBF=0. This gives SOSPCR = 0x0C6E to send the commands and
after initialization switch over to 0xE6E for 14 bits to send the first
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 commands
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 = High
You cannot use SSEL for the CS line, the SSEL line will go inactive
between datatransfers.
Think I still prefer an I2C display, SPI only makes sense if you have a
larger (graphical) display.
Good luck,
RobMessage
Re: [lpc2000] LPC2131 SPI problem
2005-10-01 by Rob Jansen
Attachments
- No local attachments were found for this message.