使用:MPLAB X IDE v3.35H
ARMony2.00bPIC32MX340F512HI像这样配置SPI:驱动程序模式:中断模式SPI中断优先级:INT_PRIORITY_LEVEL1SPI中断子优先级:INT_SUBPRIORITY_LEVEL0.:主模式数据宽度:8位缓冲模式:标准允许空闲运行协议类型:DRV_SPI_PROTOCOL_TYPE_STANDARDClock使用:CLK_BUS_PERIPHERAL_2SPI点击率-Hz:1000000时钟模式:DRV_SPI_CLOCK_MODE_IDLE_LOW_EDGE_RISE输入阶段:SPI_INPUT_SAMPLING_PHASE_IN_MIDDLEDON不使用队列中的DMAMax作业:10最小为实例保留的作业队列数量:1I像这样设置:PI作业:但是回调MCP3903A SistaBCB1从来没有运行过。当我在system_inter..c中添加断点时,我发现_IntHandlerSPIInstance0从不运行,因此DRV_SPI_Tasks从不被调用。但是,当我添加这样的SPI工作:…经过一些代码检查,我发现了代码的可疑差异:DRV_SPI_BufferAddWriteRead2DRV_SPI_BufferAddWrite2DRV_SPI_BufferAddWrite2DRV_SPI_BufferAddRead2是bug,还是我使用DRV_SPI_BufferAddWriteRead2不正确?
以上来自于百度翻译
以下为原文
Using:
- MPLAB X IDE v3.35
- Harmony 2.00b
- PIC32MX340F512H
I configure up SPI like this:
- Driver Mode: Interrupt Mode
- SPI Interrupt Priority: INT_PRIORITY_LEVEL1
- SPI Interrupt Sub-priority: INT_SUBPRIORITY_LEVEL0
- Mode: Master Mode
- Data Width: 8-bit
- Buffer Mode: Standard
- Allow Idle Run
- Protocol Type: DRV_SPI_PROTOCOL_TYPE_STANDARD
- Clock To Use: CLK_BUS_PERIPHERAL_2
- SPI Click Rate - Hz: 1000000
- Clock Mode: DRV_SPI_CLOCK_MODE_IDLE_LOW_EDGE_RISE
- Input Phase: SPI_INPUT_SAMPLING_PHASE_IN_MIDDLE
- Don't Use DMA
- Max Jobs In Queue: 10
- Minimum Number of Job Queue Reserved For Instance: 1
I set up SPI like this:
// start SPI for ADC
app_data.adc_spi = DRV_SPI_Open(DRV_SPI_INDEX_0, DRV_IO_INTENT_READWRITE);
if (DRV_HANDLE_INVALID == app_data.adc_spi) {
return;
}
DRV_SPI_CLIENT_DATA adc_spi_client_data = {
.opera
tionStarting = APP_adc_select,
.operationEnded = APP_adc_unselect
};
if (DRV_SPI_ClientConfigure(app_data.adc_spi, &adc_spi_client_data) < 0) {
return;
}
Later, I add an SPI job:
DRV_SPI_BufferAddWriteRead2(mcp3903_spi_handle, mcp3903_spi_tx_buffer, 13, mcp3903_spi_rx_buffer, 13, mcp3903_start_cb_1, NULL, NULL);
But the callback mcp3903_start_cb_1 never runs. When I add a breakpoint in system_interrupt.c , I discovered that _IntHandlerSPIInstance0 never runs, so DRV_SPI_Tasks is never called. However, when I add the SPI job like this:
DRV_SPI_BufferAddWrite2(mcp3903_spi_handle, mcp3903_spi_tx_buffer, 13, mcp3903_start_cb_1, NULL, NULL);
... the interrupt runs.
After some code inspection, I found suspicious differences in code:
DRV_SPI_BufferAddWriteRead2
if (pDrvObject->taskMode == DRV_SPI_TASK_MODE_ISR)
{
pDrvObject->txEnabled = true;
SYS_INT_SourceEnable(pDrvObject->txInterruptSource);
}
DRV_SPI_BufferAddWrite2
if (pDrvObject->taskMode == DRV_SPI_TASK_MODE_ISR)
{
pDrvObject->txEnabled = true;
pDrvObject->rxEnabled = true;
SYS_INT_SourceEnable(pDrvObject->txInterruptSource);
/* Trigger SPI interrupt for the first time for the devices which don't have persistent interrupt */
_DRV_SPI_INTERRUPT_TRIGGER(pDrvObject->txInterruptSource);
}
DRV_SPI_BufferAddRead2
if (pDrvObject->taskMode == DRV_SPI_TASK_MODE_ISR)
{
pDrvObject->rxEnabled = true;
SYS_INT_SourceEnable(pDrvObject->rxInterruptSource);
SYS_INT_SourceEnable(pDrvObject->txInterruptSource);
/* Trigger SPI interrupt for the first time for the devices which don't have persistent interrupt */
_DRV_SPI_INTERRUPT_TRIGGER(pDrvObject->rxInterruptSource);
}
Is this a bug, or am I usingDRV_SPI_BufferAddWriteRead2incorrectly?
0