你好,
我使用了adsp-sc5xx_ez-kit评估板来调试SPI + DMA。从MCU接收数据,该MCU可以生成DMA中断,但不能接收DMA数据。
以下是MCU发送给DSP的数据波形:
可以产生DMA中断,但是RxBuffer中没有数据。
附件是我的代码。你能告诉我问题是什么吗?
最好,
凯文
你好,
我使用了adsp-sc5xx_ez-kit评估板来调试SPI + DMA。从MCU接收数据,该MCU可以生成DMA中断,但不能接收DMA数据。
以下是MCU发送给DSP的数据波形:
可以产生DMA中断,但是RxBuffer中没有数据。
附件是我的代码。你能告诉我问题是什么吗?
最好,
凯文
对不起,无法添加附件,以下是我的代码:
#include <stdio.h>
#include "adi_initialize.h"
#include <drivers/spi/adi_spi.h>
#include <services/int/adi_int.h>
/* flag indicating if SPI processing is complete */
static bool bComplete = false;
/* SPI driver memory */
uint8_t SPIDriverMemory[ADI_SPI_DMA_MEMORY_SIZE];
/* SPI driver handle */
ADI_SPI_HANDLE hDevice;
/* driver API result code */
ADI_SPI_RESULT result;
/* transceiver buffers */
//section("seg_dmda_nw")
uint8_t Prologue[4] = {0x00, 0x01, 0x02, 0x03};
//section("seg_dmda_nw")
uint8_t TxBuffer[10] = {0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03};
//section("seg_dmda_nw")
uint8_t RxBuffer[10];
/* transceiver configurations */
ADI_SPI_TRANSCEIVER Transceiver1 = {&Prologue[0], 4, &TxBuffer[0], 8, &RxBuffer[0], 8};
ADI_SPI_TRANSCEIVER Transceiver2 = {NULL, 4, &TxBuffer[0], 8, NULL, 0};
ADI_SPI_TRANSCEIVER Transceiver3 = {NULL, 0, NULL, 0, &RxBuffer[0], 10};
/* SPI callback */
uint32_t spi_rx_cont = 0;
void SpiCallback(void* pHandle, uint32_t u32Arg, void* pArg)
{
ADI_SPI_HANDLE pDevice = (ADI_SPI_HANDLE *)pHandle;
ADI_SPI_EVENT event = (ADI_SPI_EVENT)u32Arg;
uint16_t *data = (uint16_t*)pArg;
switch (event) {
case ADI_SPI_TRANSCEIVER_PROCESSED:
bComplete = true;
spi_rx_cont++;
break;
default:
break;
}
}
uint32_t rx_addr = 0;
int main(void)
{
adi_initComponents();
*pREG_SPU0_SECUREP70=0x3;
*pREG_SPU0_SECUREP64=0x3;
*pREG_SPU0_SECUREP65=0x3;
/* open the SPI driver */
result = adi_spi_Open(1, SPIDriverMemory, (uint32_t)ADI_SPI_DMA_MEMORY_SIZE, &hDevice);
result = adi_spi_SetMaster(hDevice, false);
result = adi_spi_SetClockPhase(hDevice, true);
result = adi_spi_SetHwSlaveSelect(hDevice, true);
/* Register a callback for the DMA */
result = adi_spi_RegisterCallback(hDevice, SpiCallback, NULL);
/* Enable DMA */
result = adi_spi_EnableDmaMode(hDevice, true);
/* generate tx data interrupt when watermark level breaches 50% level */
/* DMA watermark levels are disabled because SPI is in interrupt mode */
// result = adi_spi_SetTxWatermark(hDevice,
// ADI_SPI_WATERMARK_50,
// ADI_SPI_WATERMARK_DISABLE,
// ADI_SPI_WATERMARK_DISABLE);
/* generate rx data interrupt when watermark level breaches 50% level */
/* DMA watermark levels are disabled because SPI is in interrupt mode */
result = adi_spi_SetRxWatermark(hDevice,
ADI_SPI_WATERMARK_NOT_EMPTY,
ADI_SPI_WATERMARK_DISABLE,
ADI_SPI_WATERMARK_DISABLE);
while(1)
{
/* submit the SPI transceiver's buffers */
result = adi_spi_SubmitBuffer(hDevice, &Transceiver3);
while(!bComplete)
{
/* do other processing here while SPI is processing */
NOP();
}
bComplete = false;
}
}
Moving to CrossCore Embedded Studio and Add-ins Community.
Hello,
We have understood that you are using ADSP-SC573 EZkit for your application. Please confirm whether our understanding is correct
We have verified SPU, SPI and Callback registration configurations in the provided code snippet.
Everything seems correct regarding the slave RX configurations in the code.
We are suspecting that hardware connections between MCU and DSP SPI pins because SPI1 TX fifo(54A300A9) is loaded (from your screenshot)
Please ensure that you have properly pin muxed for SPI pins (CLK, MOSI, SS) and if possible provide your hardware connection details.
To narrow down the issue, please try to debug as we suggested below
1.Set the breakpoints in DmaDataIntHandler and DmaErrorIntHandler in adi_dma_bf60x.c(path-Disk:\Analog Devices\CrossCore Embedded Studio <version>\SHARC\lib\src\services\Source\dma)to verify which handler has to be raised by DMA and also while hitting the breakpoint verify the DMA25 register values. Please provide us screenshot of DMA25.
Please let us know in which version of CCES you are using.
If possible, kindly provide your project to debug it in our side.
Regards,
Santha kumari.K
Hi Santha kumari.K,
Thank you for your answer.
Sorry, the information I gave you is not complete.
I am using CCES2.9.1. Attached below is my hardware connection configuration and DMA25 register status.
In addition, the attachment is my adsp-sc573-spi_test project.
Best,
Kevin
Hello,
We have verifed the code and debug it in our side. We didn't do any modifications in slave side.
To simulate the issue we have added master code(by using macro ADI_TEST) in your project.
In this project SPI2(master) communicates with SPI1(slave) over ports in ADSP-SC573EZKIT. Here P3-SPI2 has to be connected to P2(SIGMASTUDIO tag) SPI1 as below provided connections.
* Connections
* 1. Communications between port P3 and P2(SIGMA STUDIO tag)
* 2. SPI2_CLK PB_14(PIN 7)------ (PIN 7) SPI1_CLK PC_07
* 3. SPI2 MOSI PB_11(PIN 8)------ (PIN 8) SPI1 MOSI PC_09
* 4. SPI2 MISO PB_10(PIN 5)------ (PIN 5) SPI1 MISO PC_08
* 5. SPI2 SEL1 PB_15(PIN 9)------ (PIN 9) SPI1 SEL3 PF_11
We can able to receive the data . please find the attached screenshot and project.
To narrow down the issue please try the following suggestions.
1.Now please try the MCU(master TX) -DSP(slave Rx) scenario only.
Comment the submit buffer API using for tranceiver 2 - adi_spi_SubmitBuffer(hDevice, &Transceiver2);
Please ensure that DSP slave rx code has to be run first and after that run your MCU master side TX code.
2.Set the breakpoints in DmaDataIntHandler and DmaErrorIntHandler in adi_dma_bf60x.c(path-Disk:\Analog Devices\CrossCore Embedded Studio <version>\SHARC\lib\src\services\Source\dma) to verify which handler has to be raised by DMA and also while hitting the breakpoint verify the DMA25 register values. Please provide the screenshot of DMA 25 at this stage.
We hope there is no problem in RX code side.
So please provide details of hardware connections between MCU and SPI whether you are using extender(E13-1A or E13-1B/C) or P2 sigma studio tag.
Regards,
Santha kumari.K
Hi Santha kumari.K,
Thank you for your answer.
The problem was solved, the example worked well on our own product (ADSP21573(SPI0)+RT1052), but I couldn't receive the data after adding the example to the complex project. Then I referred to the I2S driver and added the section("seg_dmda_bw") before RxBuff, and the problem was also solved.
Best,
Kevin