We have a project where we need SPI.
We have full communication using bitbanging, but we can't get it to work using the peripheral.
On the logic analyser all signals seem to be correct (and identical to bitbanging, except timing), but the read register is empty.
What are we doing wrong?
void test_spi(void)
{
SSP_ConfigFormat ssp_format;
Chip_SSP_DATA_SETUP_T xf_setup;
Chip_SYSCTL_PeriphReset(RESET_SSP0);
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_IOCON);
Chip_GPIO_Init(LPC_GPIO);
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO0_9, IOCON_FUNC1);
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO0_8, IOCON_FUNC1);
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO2_11, IOCON_FUNC1);
//init SSN:
Chip_GPIO_SetPinOutHigh(LPC_GPIO, 0, 2);
Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 2);
Chip_GPIO_SetPinOutHigh(LPC_GPIO, 0, 2);
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SSP0);
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SSP1);
Chip_SSP_Init(LPC_SSP0);
Chip_SSP_Int_Enable(LPC_SSP0);
Chip_SSP_SetFormat(LPC_SSP0, SSP_BITS_8, SSP_FRAMEFORMAT_SPI, SSP_CLOCK_CPHA0_CPOL0);
Chip_SSP_Enable(LPC_SSP0);
slave_select_set();
Chip_SSP_SendFrame(LPC_SSP0, 0x28);
nfc_buffer[0] = Chip_SSP_ReceiveFrame(LPC_SSP0);
Chip_SSP_SendFrame(LPC_SSP0, 0x80);
nfc_buffer[1] = Chip_SSP_ReceiveFrame(LPC_SSP0);
slave_select_clear();
}
Does anybody have experience with SPI on the LPC11C24? A working example would be nice. Preferably one with direct writing to registers so it is independent of libraries.
Ps: I'm on NXP's forum for almost 5 years(including LPC-expresso), but post are still moderated. Weird.
Hi Chris,
I did a test with the OM13093 LPCXpresso board for LPC11C24 using <lpcopen_v2_00a_keil_iar_nxp_lpcxpresso_11c24> software package with [periph_ssp] demo.
For I only have one OM13093 board on hand, I short connect the LPC11C24 PIO0_8(MISO) & PIO0_9(MOSI) together.
I disable the LOOPBACK_TEST macro definition.
After the demo code run, I could find Rx_Buf array with Tx_Buf array value:
The SPI analyzer also shows the MOSI with the same data of MISO:
I think you could refer this [periph_ssp] demo as a start point.
Wish it helps.
Have a great day,
Mike
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thanks. This helps!
Hi,
What's the external SPI device?
Please check if you are following SPI device read sequence.
Have a great day,
Mike
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
It is the PN532 NFC reader. But even connecting MOSI to MISO gives an empty result.
Like I said we got it working with bitbanging, but want to get the spi peripheral working (also for other projects).
The read sequence may not be correct in this particular snippet, but we should get a result other than 0.
Hi,
I would recommend to submit an online support case about PN532 NFC reader product.
There with experienced NFC technical support engineers to support your question.
Please follow below thread to submit a technical case:
https://community.nxp.com/docs/DOC-329745
Thank you for the attention.
best regards,
Mike