6 years, 5 months ago.

Multiple SPI with LPC1549

I have the following setup: - nrf24l01+ radio on one spi (pins D11,D12,D13, which is the SPI marked in the pinout diagram) - flashair sd card on one spi (pins D5,D6,D7)

(I am working with the assumption that the switch matrix will allow you to do initialize two separate spi objects on two separate sets of arbitrary pins)

When used alone, either one works.

If I first initialize the sd card, I can talk to it. If I then initialize the radio after this, the radio will work, but the sd card will stop working: There is a failed spi.write inside the sd card code for the next command I send it.

I tried the same code on an lpc1768, with the hardcoded spi0 and spi1 ports (which correspond to the pin numbers I have chosen to use on the lpc1549), and there everything works together as expected.

Is there some known issue with having more than one spi object on lpc1549?

Question relating to:

Update: After changing around the order I send spi commands to the two devices, I now have it working on both LPC1768 and LPC1549.

There appears to be a bug somewhere that causes some combinations of spi calls to succeed on LPC1768 but fail on LPC1549, but I suspect that is an issue with one of the libraries I am using, and not the LPC1549 SPI implementation.

posted by Per J. G. 02 Feb 2015

1 Answer

6 years, 5 months ago.


I recall the SPI implementation is different than other targets, might help looking at it how SPI are assigned https://github.com/mbedmicro/mbed/blob/master/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/spi_api.c

Thanks for the tip.

I stepped through the calls to get_available_spi in LPCXpresso, and the two SPI ports seem to be assigned properly. The SD card is initialized first and ends up on SPI0, and the radio goes to SPI1.

However, I still have the same error: When I send data on the SD card SPI0, the radio on SPI1 stops working. (and it is working on LPC1768).

posted by Per J. G. 15 Jan 2015

Take logic analyzer and check if signals are getting out from SPI1 .. You can share them with us, there might be somebody with this target whoc an test it ;) might be beneficial to write a simple test (look at mbed SDK test directory /mbed/test/ ), where you would initialize those 2 SPI and send few bytes of data , plus with screen how the communication looks like.

There could be a bug in SPI implementation for this target.

posted by Martin Kojtal 15 Jan 2015