The timing of data transfer and 4-byte data from "spi_polling_b2b_transfer_master.c" sample code.

cancel
Showing results for 
Search instead for 
Did you mean: 

The timing of data transfer and 4-byte data from "spi_polling_b2b_transfer_master.c" sample code.

Jump to solution
398 Views
larry781111
Contributor I

The timing of data transfer and 4-byte data from "spi_polling_b2b_transfer_master.c" sample code.

I would like to transfer(write and then read the response from slave), the format is both 4-byte.

Is it correct to exchange "uint8_t srcBuff" to "uint32_t srcBuff"?

Should I change the "uint8_t *txData, *rxData" from function SPI_MasterTransferBlocking?

If my polling period is 10 mSec, how to adjust from the example code?

/*******************************************************************************
* Variables
******************************************************************************/
#define BUFFER_SIZE (64)
static uint8_t srcBuff[BUFFER_SIZE];
static uint8_t destBuff[BUFFER_SIZE];

status_t SPI_MasterTransferBlocking(SPI_Type *base, spi_transfer_t *xfer)
{
int32_t instance;
uint32_t tx_ctrl = 0, last_ctrl = 0;
uint32_t tmp32, rxRemainingBytes, txRemainingBytes, dataWidth;
uint32_t toReceiveCount = 0;
uint8_t *txData, *rxData;
uint32_t fifoDepth;

Labels (1)
0 Kudos
1 Solution
243 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi YuChia Chien,

    Next time, when you create the question, please also share the LPC chip partnumber you are using, and tell us the code source.

   It seems you are using the LPC5460X, and the SDK code for LPC5460X.

   1. 4 byte data transfer

     No, you don't need to modify the unit8_t to uint32, please modify the dataSize to 4, like the following picture:

pastedImage_1.png

2. If my polling period is 10 mSec, how to adjust from the example code?

I can't totally understand your question.

What do you mean the 10ms period, do you want to change the SPI baud rate?

If you want to change the SPI baudrate, you can change     config->baudRate_Bps = 500000U; in function void SPI_MasterGetDefaultConfig(spi_master_config_t *config).

Wish it helps you~!
Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
5 Replies
243 Views
li-chinwang
Contributor II

I check its ssel, it is always low even transaction is done.

Please check it

0 Kudos
243 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Li-Chin,

   If you want to control the SSEL freely, I suggest you configure the SSEL as the GPIO, then use the gpio to control SSEL pin freely with the code.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
243 Views
larry781111
Contributor I

Hi Kerry,

Thanks your reply.

My chip is LPC51U68 and I use on OM40005.

1. For the first question, I need to transfer 4-byte data in a time. The actual value is 0x80000000.

How to assign the value to srcBuff.

2. What I mean is that after Master transfer the value 0x80000000, need to wait 10 msec then receive the  response from slave.

0 Kudos
243 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi YuChia,

  You can assign the value to srcBuff like this:

srcBuff[0]=0x80;

srcBuff[1]=0x00;

srcBuff[2]=0x00;

srcBuff[3]=0x00;

or you also can define srcBuff as unint32, then set srcBuff[0]=0x80000000; but the dataSize need to be 4, 

SPI have MISO, MOSI, when you send the data to MOSI, the input data will enter the MISO at the same time, so you don't need to wait 10msec, otherwise your receive is in the next SPI frame.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
244 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi YuChia Chien,

    Next time, when you create the question, please also share the LPC chip partnumber you are using, and tell us the code source.

   It seems you are using the LPC5460X, and the SDK code for LPC5460X.

   1. 4 byte data transfer

     No, you don't need to modify the unit8_t to uint32, please modify the dataSize to 4, like the following picture:

pastedImage_1.png

2. If my polling period is 10 mSec, how to adjust from the example code?

I can't totally understand your question.

What do you mean the 10ms period, do you want to change the SPI baud rate?

If you want to change the SPI baudrate, you can change     config->baudRate_Bps = 500000U; in function void SPI_MasterGetDefaultConfig(spi_master_config_t *config).

Wish it helps you~!
Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos