When master SPI read data from slave SPI, the master will generate SPI CLK/PCS Low, the slave will clock data out from Sout.
I use SM1_ReceiveBlock() to read data from slave, there is no SPI CLK out from master, and it doesn't go the the PE_ISR(SM1_Interrupt).
I check SM1_SendBlock(), it works. There is "SPI_PDD_EnableDmasInterrupts(SPI0_BASE_PTR, SPI_PDD_TX_FIFO_FILL_INT_DMA);" .
In function "SM1_ReceiveBlock()", should add "SPI_PDD_EnableDmasInterrupts(SPI0_BASE_PTR, SPI_PDD_RX_FIFO_DRAIN_INT_DMA); " ?
Also, what is the proper way to generate SPI CLK during read data from slave?
Regards
Sam
Hi,
I am not sure if you are using interrupt service or not, anyway please check the attached document in the typical usage section to see how the SPI_Master component is used.
Basically you need to write the following:
SM1_ReceiveBlock(MySPIPtr, InpData, BLOCK_SIZE); /* Request data block reception this is used to tell the driver how many bytes will be received and where they will be stored*/
SM1_SendBlock(MySPIPtr, OutData, BLOCK_SIZE); /*To provide clock for slave, master sends anything that is as long as
expected answer from slave. length(msgDummy) = length(msgSlave) Outdata can be 0x00 or 0xFF commonly */
/* Master waits for data from slave */
while (SM1_GetBlockReceivedStatus(masterDevData) == FALSE) ;
Hope this information can help you
Best Regards,
Adrian Sanchez Cano
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Adrian,
It still require to enable the SPI Rx interrupt,
Here is my code, it works now.
SPI_PDD_EnableDmasInterrupts(SPI0_BASE_PTR, SPI_PDD_RX_FIFO_DRAIN_INT_DMA); /* Enable RX interrupt */
SM1_ReceiveBlock(spiMasterDevData, &RxData[0], 2);
SM1_SendBlock(spiMasterDevData, &CMDData[0], 2);
Regards
Sam
Hello Sam,
After you add the component "SPIMster_LDD" , you can refer to the Typical Usage .
there have two demo , with interrupt and without , it show how to configure and use the SPI.
IF it still have not meet your demand, please tell me your chip .
Have a great day,
Alice
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------