Part Number:CC2640R2FOther Parts Discussed in Thread:ADS1291
最近进行SPI读取ADS1291数据,感觉数据读取的频率不是很稳定。考虑是不是使用dma会好一些。
然后看了spi程序,感觉spi已经配置了DMA,想确定下是不是这样的。
const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[BOARD_SPICOUNT] = {
{
.baseAddr = SSI0_BASE,
.intNum = INT_SSI0_COMB,
.intPriority = ~0,
.swiPriority = 0,
.powerMngrId = PowerCC26XX_PERIPH_SSI0,
.defaultTxBufValue = 0,
.rxChannelBitMask = 1<<UDMA_CHAN_SSI0_RX,
.txChannelBitMask = 1<<UDMA_CHAN_SSI0_TX,
.mosiPin = BOARD_SPI0_MOSI,
.misoPin = BOARD_SPI0_MISO,
.clkPin = BOARD_SPI0_SCK,
.csnPin =BOARD_SPI0_CSN
}
};
//spi_config 包含对dma配置???
const SPI_Config SPI_config[BOARD_SPICOUNT] = {
{
.fxnTablePtr = &SPICC26XXDMA_fxnTable,
.object = &spiCC26XXDMAObjects[BOARD_SPI0],
.hwAttrs = &spiCC26XXDMAHWAttrs[BOARD_SPI0]
}
};
/* SPI function table for SPICC26XXDMA implementation */
const SPI_FxnTable SPICC26XXDMA_fxnTable = {
SPICC26XXDMA_close,
SPICC26XXDMA_control,
SPICC26XXDMA_init,
SPICC26XXDMA_open,
SPICC26XXDMA_transfer,
SPICC26XXDMA_transferCancel
};
SPI_Handle SPI_open(uint_least8_t index, SPI_Params *params)
{
SPI_Handle handle = NULL;
if (isInitialized && (index < SPI_count)) {
/* If params are NULL use defaults */
if (params == NULL) {
params = (SPI_Params *) &SPI_defaultParams;
}
/* Get handle for this driver instance */
handle = (SPI_Handle)&(SPI_config[index]);
handle = handle->fxnTablePtr->openFxn(handle, params);
}
return (handle);
}
SPIHandle = SPI_open(BOARD_SPI0, &SPIparams);
在传输的时候是不是应该使用SPICC26XXDMA_transfer,而不是SPI_transfer();?
caiyu:
SPI_transfer()最后调用的还是SPICC26XXDMA_transfer。
void SPI_transferCancel(SPI_Handle handle){ handle->fxnTablePtr->transferCancelFxn(handle);}
const SPI_FxnTable SPICC26XXDMA_fxnTable = { SPICC26XXDMA_close, SPICC26XXDMA_control, SPICC26XXDMA_init, SPICC26XXDMA_open, SPICC26XXDMA_transfer, SPICC26XXDMA_transferCancel};
typedef struct { /*! Function to close the specified peripheral */ SPI_CloseFxn closeFxn;
/*! Function to implementation specific control function */ SPI_ControlFxn controlFxn;
/*! Function to initialize the given data object */ SPI_InitFxn initFxn;
/*! Function to open the specified peripheral */ SPI_OpenFxn openFxn;
/*! Function to initiate a SPI data transfer */ SPI_TransferFxn transferFxn;
/*! Function to cancel SPI data transfer */ SPI_TransferCancelFxn transferCancelFxn;} SPI_FxnTable;
const SPI_Config SPI_config[EEG_BOARD_SPICOUNT] = { { .fxnTablePtr = &SPICC26XXDMA_fxnTable, .object = &spiCC26XXDMAObjects[EEG_BOARD_SPI0], .hwAttrs = &spiCC26XXDMAHWAttrs[EEG_BOARD_SPI0] }};
,
Katherine Wang:
感谢您对TI产品的关注!已为您咨询TI资深工程师,一旦得到回复会立即回复给您。
,
Katherine Wang:
正如您所发现的,SPI TI Driver驱动程序确实使用 DMA 外设。您应该使用 SPI_transfer,它将映射到 SPICC26XXDMA_transfer 的正确执行。请参考spimaster和spimaster示例并具体说出您观察到的不稳定之处,最好能够附上终端输出日志和逻辑分析器屏幕截图。