微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI WIFI设计交流 > CC3200 SPI DMA 传输数据错误

CC3200 SPI DMA 传输数据错误

时间:10-02 整理:3721RD 点击:

您好:

       在用SPI DMA  SLAVE 方式与设备传输时,大概率出现数据传输错误,感觉像是CLK不匹配导致。现在MASTER SPI CLK是12M,SLAVE方式时CLK 应该与MASTER同步。cc3200对时钟有什么要求么?需要连续时钟吗?有没有特殊的同步机制。下面是spi的初始化代码,麻烦帮忙看看有什么问题,谢谢。

    

MAP_SPIConfigSetExpClk(GSPI_BASE,MAP_PRCMPeripheralClockGet(PRCM_GSPI),
SPI_IF_BIT_RATE,mode,SPI_SUB_MODE_3,
(chip_select |
SPI_4PIN_MODE |
SPI_TURBO_OFF |
SPI_CS_ACTIVELOW |
SPI_WL_8));
MAP_SPIIntRegister(GSPI_BASE,interrupt_handler);
MAP_SPIFIFOLevelSet(GSPI_BASE, 1, 1);
MAP_SPIFIFOEnable(GSPI_BASE, SPI_RX_FIFO);
MAP_SPIFIFOEnable(GSPI_BASE, SPI_TX_FIFO);
MAP_SPIDmaEnable(GSPI_BASE,SPI_RX_DMA);
MAP_SPIDmaEnable(GSPI_BASE,SPI_TX_DMA);
MAP_SPIWordCountSet(GSPI_BASE, SPI_DMA_MAX_LENGTH);
MAP_SPIIntEnable(GSPI_BASE, SPI_INT_EOW);
MAP_SPIEnable(GSPI_BASE);

SPI_DMA_MAX_LENGTH 为1024;

Transfer的设置:

MAP_SPIDisable(GSPI_BASE);
UDMASetupTransfer(UDMA_CH30_GSPI_RX, UDMA_MODE_BASIC, dma_size, UDMA_SIZE_8,
UDMA_ARB_1, (void *) (GSPI_BASE + MCSPI_O_RX0), UDMA_SRC_INC_NONE, rx,
UDMA_DST_INC_8);
UDMASetupTransfer(UDMA_CH31_GSPI_TX, UDMA_MODE_BASIC, dma_size, UDMA_SIZE_8,
UDMA_ARB_1, tx, UDMA_SRC_INC_8, (void *) (GSPI_BASE + MCSPI_O_TX0),
UDMA_DST_INC_NONE);
MAP_SPIEnable(GSPI_BASE);

作为主机模式应该没有大问题吧?是全错误呢,还是偶尔错误。你降低一下CLK试试有没有改观。

其中TI给的有那个例程,看看有没有类似的例子,我知道有个主机模式的例子。没试过从机,最近重装没安装那个软件。

可以参考一个SPI DMA的例子,

https://github.com/severin-kacianka/cc3200_dma_spi_example/

cc3200_dma_spi_example

Here are two examples that show how to use SPI with DMA and FIFO on the CC3200. I hope that they are a useful starting point for anyone, who wants to work on SPI and DMA in the future.

The examples are compiling fine on Linux with gcc 4.9.3 from http://launchpad.net/gcc-arm-embedded. All you need to change is the path for the SDK in the Makefile. The hardware setup is similar to the SPI example in the SDK: just connect two CC3200 via cable (Pins GND, P05, P06, P07 and P08). I have set the following jumpers: J6, J7, J8. J9. J10, J11, J12, J13.

simple_spi_transfer is an example of an SPI transfer without DMA and FIFO. The master sends a buffer to the slave, reads it back in the next transfers and verifies the checksums.

transfer_1024_byte implements a simple SPI/DMA transfer that will transfer 1024 (or whatever DMA_SIZE is set to) bytes from the master to the slave and back. It then calculates the buffer's CRC checksum and (on the master) compares the send checksum to the received checksum.

transfer_64k shows how to transfer a 64k buffer from the master to the slave and back again.

windows contains a Makefile send to me by Matt van de Werken that also works using the Launchpad tools in a Cygwin enviroment

谢谢,dma可以跑通,最后查出来是飞线干扰的问题

谢谢,dma可以跑通,最后查出来是飞线干扰的问题

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top