LPC11C24 SPI read not working

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

LPC11C24 SPI read not working

2,206 次查看
chrisidema
Contributor I

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();
}
       

标签 (1)
0 项奖励
回复
6 回复数

1,897 次查看
chrisidema
Contributor I

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.

0 项奖励
回复

1,897 次查看
Hui_Ma
NXP TechSupport
NXP TechSupport

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:

pastedImage_1.png

The SPI analyzer also shows the MOSI with the same data of MISO:

pastedImage_2.png

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!
-----------------------------------------------------------------------------------------------------------------------

1,897 次查看
chrisidema
Contributor I

Thanks. This helps!

0 项奖励
回复

1,897 次查看
Hui_Ma
NXP TechSupport
NXP TechSupport

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!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

1,897 次查看
chrisidema
Contributor I

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.

0 项奖励
回复

1,897 次查看
Hui_Ma
NXP TechSupport
NXP TechSupport

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

0 项奖励
回复