工具/软件:
您好、
美好的一天!
有客户的问题、您能提供帮助吗? 非常感谢。
将 McBSP 配置为 SPI 后、我想询问速度问题。
我观察到从数据写入 DXR1 到使用示波器实际在总线上发送数据之间的延迟约为 550ns。
我无法在手册中找到导致此延迟的具体信息。
示波器图像如下所示:蓝线的第一个下降沿表示数据写入 DXR1 的时刻、粉色线为 MCLKXA、黄线为 MDXA、波特率配置为 9.425MHz。

我主要想了解:1) 什么原因导致了延迟? 2) 是否可以减少延迟以提高带宽利用率?
Uint16 McbspBSpiTxRx8Bit(Uint16 txByte)
{
Uint16 rxByte = 0U;
Uint16 i = 0U;
while((gMcbspbRegs.SPCR2.bit.XRDY == 0U) && (i < MCBSP_TIMEOUT_LOOP_CTRL_200))
{
DELAY_US(MCBSP_DELAY_TIME_100NS);
i++;
}
gMcbspbRegs.DXR1.all = txByte & 0xFFU; /* send data */
i = 0U;
while((gMcbspbRegs.SPCR1.bit.RRDY == 0U) && (i < MCBSP_TIMEOUT_LOOP_CTRL_200))
{
DELAY_US(MCBSP_DELAY_TIME_100NS);
i++;
}
rxByte = gMcbspbRegs.DRR1.all & 0xFFU; /* receive data */
return rxByte;
}
MCBSP配置代码如下:
Uint16 McbspConfig(volatile struct mcbsp_regs_t *mcbsp, const TY_SPI_CONFIG *config)
{
mcbsp->SPCR2.all = 0x0000U; /* Reset frame synchronization generator, sample rate generator, transmitter */
mcbsp->SPCR2.bit.FREE = 1U; /* debug, when a breakpoint is encountered, the transfer clock continues to run */
mcbsp->SPCR1.all = 0x0000U; /* Reset receiver, right set word, turn off digital loopback */
mcbsp->PCR.all = 0x0F08U; /* Configure as master */
mcbsp->RCR2.bit.RDATDLY = 1U; /* The data receiving delay bit is set to 1 on the master */
mcbsp->XCR2.bit.XDATDLY = 1U; /* The delay bit for sending data is set to 1 on the master */
mcbsp->SPCR1.bit.DXENA = 1U;
mcbsp->SPCR1.bit.CLKSTP = ((0xA >> 2U)& 0x03U); /* Get the second or third bit */
mcbsp->PCR.bit.CLKXP = ((0xA >> 1U) & 0x01U); /* Get the first bit */
mcbsp->PCR.bit.CLKRP = (0xA & 0x01U); /* Get the 0th bit */
mcbsp->MFFINT.bit.XINT = 0u;
mcbsp->RCR1.bit.RWDLEN1 = 0; /* Configure the word size to receive data, macros available */
mcbsp->XCR1.bit.XWDLEN1 = 0; /* Configure the word size to send data, macros available */
mcbsp->SRGR2.all = 0x2000U; /* Determine the value,CLKSM=1, frame synchronization pulse period FPER =1 CLKG period */
mcbsp->SRGR1.all = 7; /* Used to configure clock rate CLKG and CLKG cycle pulse width */
/* CLKG periodic pulse width defaults to 1 sampling period */
DELAY_US(MCBSP_DELAY_TIME_1US);
mcbsp->SPCR2.bit.GRST = 1U; /* Enable the sample rate generator */
DELAY_US(MCBSP_DELAY_TIME_1US);
mcbsp->SPCR2.bit.XRST = 1U; /* Enable sender from reset */
mcbsp->SPCR1.bit.RRST = 1U; /* Enable the receiver from reset */
mcbsp->SPCR2.bit.FRST = 1U; /* Enable frame sync generator from reset */
}