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.

msp430f5529 rtos 无法驱动spi

Other Parts Discussed in Thread: MSP430F5529

使用msp430f5529运行ti-rtos驱动spi仿真发现从spi的RXBUF中有数据,程序运行时无法跳过SPI_transfer(),运行到__no_operation();。

主要的taskFxn函数如下。

void pm25ld020taskFxn(UArg arg0, UArg arg1) {


GPIO_write(ZKS_GASSENSOR_X2_SPI_PM25LD020_CE,
ZKS_GASSENSOR_X2_PM25LD020_ENABLE);

SPI_Handle spi_handle_pm25ld020;
Bool transferOK;
SPI_Params spiParams_pm25ld020;
SPI_Params_init(&spiParams_pm25ld020);
spiParams_pm25ld020.transferMode = SPI_MODE_BLOCKING;
spiParams_pm25ld020.transferCallbackFxn = NULL;
spiParams_pm25ld020.bitRate = 8000000;
spi_handle_pm25ld020 = SPI_open(Board_SPI_PM25LD020, &spiParams_pm25ld020);

SPI_Transaction spi_transaction_pm25ld020;
UChar transmitBuffer[1] = { 0x9f };
UChar receiveBuffer[4] = { 0x04 };
spi_transaction_pm25ld020.count = 4;
spi_transaction_pm25ld020.txBuf = (Ptr) transmitBuffer;
spi_transaction_pm25ld020.rxBuf = (Ptr) receiveBuffer;
transferOK = SPI_transfer(spi_handle_pm25ld020, &spi_transaction_pm25ld020);
__no_operation();
GPIO_write(ZKS_GASSENSOR_X2_SPI_PM25LD020_CE,
ZKS_GASSENSOR_X2_PM25LD020_DISABLE);
if (!transferOK) {
/* Error in SPI transfer or transfer is already in progress */
}

}

  • 你追踪一下SPI_transfer函数,看看都做了什么

  • RTOS 中的spi嵌套了dma,现在问题应该是出在DMA上,应该怎么解决呢

    DMA的配置没有修改程序如下

    Void MSP_EXP430F5529LP_isrDMA(UArg arg)
    {
    /* Call the SPI DMA function, passing the SPI handle used for WiFi */
    SPI_serviceISR((SPI_Handle) &(SPI_config[0]));
    __no_operation();
    }

    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(SPI_config, ".const:SPI_config")
    #pragma DATA_SECTION(spiUSCIBDMAHWAttrs, ".const:spiUSCIBDMAHWAttrs")
    #endif

    #include <ti/drivers/SPI.h>
    #include <ti/drivers/spi/SPIUSCIBDMA.h>

    SPIUSCIBDMA_Object spiUSCIBDMAObjects[MSP_EXP430F5529LP_SPICOUNT];
    uint8_t spiUSCIBDMAscratchBuf[MSP_EXP430F5529LP_SPICOUNT];

    const SPIUSCIBDMA_HWAttrs spiUSCIBDMAHWAttrs[MSP_EXP430F5529LP_SPICOUNT] = {
    {
    .baseAddr = USCI_B0_BASE,
    .clockSource = USCI_B_SPI_CLOCKSOURCE_SMCLK,
    .bitOrder = USCI_B_SPI_MSB_FIRST,
    .scratchBufPtr = &spiUSCIBDMAscratchBuf[0],
    .defaultTxBufValue = 0,

    /* DMA */
    .dmaBaseAddr = DMA_BASE,
    /* Rx Channel */
    .rxDMAChannelIndex = DMA_CHANNEL_1,
    .rxDMASourceTrigger = DMA_TRIGGERSOURCE_18,
    /* Tx Channel */
    .txDMAChannelIndex = DMA_CHANNEL_0,
    .txDMASourceTrigger = DMA_TRIGGERSOURCE_19
    }
    };

    const SPI_Config SPI_config[] = {
    {
    .fxnTablePtr = &SPIUSCIBDMA_fxnTable,
    .object = &spiUSCIBDMAObjects[0],
    .hwAttrs = &spiUSCIBDMAHWAttrs[0]
    },
    {NULL, NULL, NULL},
    };

  • 如果不想嵌套DMA有应该怎么实现rtos&spi