Other Parts Discussed in Thread: SYSBIOS
TI的工程师,你好。
我在使用MCSPI的时候遇到了这样一个问题,在Task中使用MCSPI_transfer没有任何问题(EDMA传输),但是在Hwi或者定时器中断回调函数中调用时就无法运行了,值得注意的是,中断回调函数是可以在正常情况下使用的,运行错误日志如下:
[t=0x02abab8e] ti.sysbios.knl.Semaphore: ERROR: line 289: assertion failure: A_badContext: bad calling context. Must be called from a Task.
[ 0.058] ti.sysbios.knl.Semaphore: line 289: assertion failure: A_badContext: bad calling context. Must be called from a Task.
[ 0.058] xdc.runtime.Error.raise: terminating execution
初始化参数配置如下:
MCSPI_Handle tMcpi;
MCSPI_Params tMcSpiParams;
MCSPI_Params_init(&tMcSpiParams);
tMcSpiParams.frameFormat = SPI_POL0_PHA0;
tMcSpiParams.transferTimeout = 0xffff;
tMcSpiParams.bitRate = MCSPI_OUT_FREQ;
tMcSpiParams.dataSize = 8;
tMcSpiParams.mode = SPI_MASTER;
tMcSpiParams.transferCallbackFxn = NULL;//atCbFxn[tInstance];
tMcSpiParams.transferMode = SPI_MODE_CALLBACK;
tMcpi = MCSPI_open(tInstance, tInstance, &tMcSpiParams);
传输参数配置如下:
SPI_Transaction tTransaction;
tTransaction.status = SPI_TRANSFER_STARTED;
tTransaction.count = 20;
tTransaction.txBuf = &tmptxbuff[0];
tTransaction.rxBuf = &tmprxbuff[0];
MCSPI_transfer(tMcpi, &tTransaction);
而我查看了MCSPI_transfer的使用说明,有这样一句描述:
In SPI_MODE_CALLBACK, MCSPI_transfer() does not block task execution and calls a MCSPI_CallbackFxn. This makes the MCSPI_tranfer() safe to be used within a Task, Swi, or Hwi context. The SPI_Transaction structure must stay persistent until the MCSPI_transfer function has completed!
可是MCSPI_transfer函数为什么不能在回调函数中使用呢?