This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP432p4111 使用库函数SPI_transfer(spi_adc, &spiTransaction);,程序挂死

您好,最近在用MSP432p4111芯片的SPI来读取FPGA数据,每当过一段时间后,就会在库函数SPI_transfer(spi_adc, &spiTransaction);这一句话挂死,导致整个程序死掉,请问这是什么情况???

  • 根据您目前的信息不太好判断问题所在,请问能否提供下详细信息吗?您是如何调用SPI_transfer的?若是可以的话,请给出相关代码或者私信一下您的工程,谢谢
  • 您好,这是SPI的配置
    .baseAddr = EUSCI_B2_BASE,
    .bitOrder = EUSCI_B_SPI_MSB_FIRST,
    .clockSource = EUSCI_B_SPI_CLOCKSOURCE_SMCLK,
    .defaultTxBufValue = 0xFF,
    .dmaIntNum = INT_DMA_INT3,
    .intPriority = (~0),
    .rxDMAChannelIndex = DMA_CH5_EUSCIB2RX0,
    .txDMAChannelIndex = DMA_CH4_EUSCIB2TX0,
    .clkPin = SPIMSP432DMA_P3_5_UCB2CLK,
    .simoPin = SPIMSP432DMA_P3_6_UCB2SIMO,
    .somiPin = SPIMSP432DMA_P3_7_UCB2SOMI,
    .stePin = 0,//SPIMSP432DMA_P3_4_UCB2STE,
    .pinMode = EUSCI_SPI_3PIN,//EUSCI_SPI_4PIN,
    .minDmaTransferSize = 100
    我将minDmaTransferSize 这个参数从10改成了100以后,这个死机现象明显减少,请问改这个参数具体影响的是那一部分嘛?
  • 附上SPI配置和SPITransaction的配置
    SPI_Params_init(&spiParams);
    spiParams.dataSize = 8;
    spiParams.bitRate = 12000000;
    spiParams.transferMode = SPI_MODE_BLOCKING; //SPI_MODE_CALLBACK;
    //spiParams.transferCallbackFxn = ***;
    spiParams.frameFormat = SPI_POL1_PHA1;
    spiHandle = SPI_open(Board_SPI2, &spiParams);


    spiTransaction.count = 4096;
    spiTransaction.txBuf = (void *) masterTxBuffer;
    spiTransaction.rxBuf = (void *) masterRxBuffer;

    麻烦您看一下,谢谢
  • 谢谢您的反馈

    在下面的链接内有相关的说明

    https://dev.ti.com/tirex/explore/content/simplelink_msp432p4_sdk_3_40_01_02/docs/tidrivers/doxygen/html/_s_p_i_m_s_p432_d_m_a_8h.html

    If the driver was opened in SPI_MODE_BLOCKING, it verifies the amount of data frames to be transfered exceeds the SPIMSP432DMA_HwAttrsV1.minDmaTransferSize before performing a transfer using the DMA. SPIMSP432DMA_HwAttrsV1.minDmaTransferSize allows users to set a minimum amount of data frames a transfer must have to perform a transfer using the DMA. If the amount of data is less than this limit, the driver performs a polling transfer (unless the device is a slave with a timeout configured). This feature is provided for situations where there is little data to be transfered & it is more efficient to simply perform a polling transfer instead of configuring the DMA & waiting until the task is unblocked.

    如果驱动程序是在SPI_MODE_BLOCKING中打开的,则在使用DMA执行传输之前,它会验证要传输的数据帧数量是否超过SPIMSP432DMA_HwAttrsV1.minDmaTransferSize。

    SPIMSP432DMA_HwAttrsV1.minDmaTransferSize允许用户设置传输以使用DMA执行传输所必需的最小数据帧数。如果数据量小于此限制,则驱动程序将执行轮询传输(除非设备是配置了超时的从属设备)。此功能用于以下情况:要传输的数据很少,而简单地执行轮询传输而不是配置DMA并等待直到任务被阻止,这样效率更高。

  • DMA非常适合传输大量数据,例如SD卡(基于SPI)数据块,但是对于低数据传输(例如20字节或更小)的传输会增加大量开销。所以我们在新版的SDK中实现了一个名为“ minDmaTransferSize”的阈值变量。该阈值变量使应用程序开发人员可以选择最小量的数据,这些数据将触发SPI驱动程序以使用DMA或非DMA。
  • 谢谢,我找到问题所在了。