Other Parts Discussed in Thread: MSPM33C321A
器件型号: MSPM33C321A
我使用 SPI 发送一个位流。 我发现 Motorola SPI 模式在字节之间留下了间隙。 TI 同步模式没有、但它在第一个字节中放置了一个额外的位。
我对“spi_controller_multibyte_fifo_poll_LP_MSPM33C321A_nortos_ticlang“示例进行了轻微修改、以显示该问题。
#include "ti_msp_dl_config.h"
/*
* Number of bytes for SPI packet size
* The packet will be transmitted by the SPI controller.
* This example uses FIFOs with polling, and the maximum FIFO size is 4.
* Refer to interrupt examples to handle larger packets.
*/
#define SPI_PACKET_SIZE (2)
/* Data for SPI to transmit */
// packet size 4
//uint8_t gExpectedRxPacket[SPI_PACKET_SIZE] = {0x1, 0x2, 0x3, 0x4};
//uint8_t gTxPacket[SPI_PACKET_SIZE] = {0xAA, 0x00, 0xFF, 0x55};
// packet size 2
uint8_t gExpectedRxPacket[SPI_PACKET_SIZE] = {0x1, 0x2};
uint8_t gTxPacket[SPI_PACKET_SIZE] = {0xAA, 0x55};
volatile uint8_t gRxPacket[SPI_PACKET_SIZE];
#ifdef __SLATE_INTERNAL__
volatile bool gTransactionCompleted = false;
#endif
int main(void)
{
SYSCFG_DL_init();
#ifdef __SLATE_INTERNAL__
__BKPT(0);
#endif
/* Fill TX FIFO with data and transmit to SPI Peripheral */
DL_SPI_fillTXFIFO8(SPI_0_INST, &gTxPacket[0], SPI_PACKET_SIZE);
/* Wait until all bytes have been transmitted and the TX FIFO is empty */
while (DL_SPI_isBusy(SPI_0_INST))
;
for (uint8_t i = 0; i < SPI_PACKET_SIZE; i++) {
gRxPacket[i] = DL_SPI_receiveDataBlocking8(SPI_0_INST);
}
#ifdef __SLATE_INTERNAL__
gTransactionCompleted = true;
#endif
/*
* If this example is used with the spi_peripheral_multibyte_fifo_poll
* example, the expected data to receive in gRxPacket is
* {0x01, 0x02, 0x03, 0x04}.
*/
/* If write and read were successful, toggle LED */
while (!DL_SPI_isTXFIFOEmpty(SPI_0_INST))
;
int allCorrect = 1;
for (int i = 0; i < SPI_PACKET_SIZE; i++) {
if (gExpectedRxPacket[i] != gRxPacket[i]) allCorrect = 0;
}
if (allCorrect == 1) {
DL_GPIO_setPins(GPIO_LEDS_PORT, GPIO_LEDS_PASS_LED_PIN);
}
else{
DL_GPIO_setPins(GPIO_LEDS_PORT, GPIO_LEDS_FAIL_LED_PIN);
}
__BKPT(0);
}
唯一真正的区别是更改发送的数据和更改 SPI 模式。
使用该示例的 Motorola 4 线 SPI 模式时、我得到:

您可以计算出字节和 16 个时钟之间有一个间隙。 当我切换到 TI 同步模式时:

间隙已消失、但现在我得到了 17 个时钟。 在我的一些测试中、它实际上会拉伸第一个脉冲、因此我可以连续获得两个脉冲、其中应该只有一个。
我没有看到与此相关的任何勘误。 我有什么问题吗?

