This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
工具与软件:
嗨、团队:
我正在查看 spi_controller_multibyte_fifo_pol_lp_MSPM0G3507示例。 如何多于4字节的数据传输? 在 FIFO 示例中、我可以传输的最大数据字节为5字节。 为什么会这样?
#define SPI_PACKET_SIZE (8) /* Data for SPI to transmit */ uint8_t gTxPacket[SPI_PACKET_SIZE] = {'M', 'S', 'P', '!', 'M', 'S', 'P', '!'}; /* Data received from SPI Peripheral */ volatile uint8_t gRxPacket[SPI_PACKET_SIZE]; int main(void) { SYSCFG_DL_init(); /* Fill TX FIFO with data and transmit to SPI Peripheral */ DL_SPI_fillTXFIFO16(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)) ; /* * Wait to receive the SPI data * This loop expects SPI_PACKET_SIZE bytes */ for (uint8_t i = 0; i < SPI_PACKET_SIZE; i++) { gRxPacket[i] = DL_SPI_receiveDataBlocking8(SPI_0_INST); } /* * 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 (1) { DL_GPIO_togglePins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN | GPIO_LEDS_USER_TEST_PIN); delay_cycles(16000000); } }
非常感谢
Matthew Chen
您是说它不传输它显示的8个信号?
尊敬的 Keith:
是的、它仅传输前5个字节被传输。 我检查了 示波器。 我有什么错吗?
Matthew
您是否连接了另一个作为外设的器件?
尊敬的 Keith:
是的、我使用另一个具有 spi_peripheral_echo_interrupts_lp_MSPM0G3507_nortos_ticlang 的电路板闪存。 同样只获得5个字节
Matthew
您看到此评论了吗?
是的、我是说有任何方法可以传输超过4字节、比如8字节? 此外、我感到困惑、因为最大值为4字节。 我可以得到5个字节的原因是什么?
我想它像是 UART TX 缓冲器。 一旦您开始加载该字节、第一个字节*立即*进入 SPI TX 缓冲区并开始传输。 然后您填充 FIFO 的其他4个字节。
要获得超过4字节、您需要按规定忙等待或使用中断。 大脑获取8个字节的方法是:
/* 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)) ; /* Fill TX FIFO with data and transmit to SPI Peripheral */ DL_SPI_fillTXFIFO8(SPI_0_INST, &gTxPacket2[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 (i = 0; i < PACKETSIZE; i++) { while (DL_SPI_isTXFIFOFull (SPI_0_INST)) ; // Put data into fifo DL_SPI_fillTXFIFO8(SPI_0_INST, &gTxPacket[i], 1); }
尊敬的 Keith:
非常感谢您的回答。 这很有帮助。
Matthew