完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,
我还没有使用DMA,现在正在考虑使用Buffer来实现SPI和SPI缓冲数据传输。 开始时,我想到了在5LP的创建者中使用示例代码。它看起来是直截了当的,但是如何在现实世界中启动传输呢? 我可以简单地把数据加载到TxBuffe中,等到传输完成,每次读取结果时,都要转载吗? Stastf(TxBuffe,“一些数据”);/ /在TX缓冲器中放入新数据 当(0U= =(SPIMULATEXTXSTATUS(和);SPIMUSTSTSSPIZIN)){} / /等待转移 对于(i=0u;i & lt;BuffelySig.;I++) { LCDAPrimthExuUtiN 8(RxPult);/ /读取接收数据 } 谢谢 以上来自于百度翻译 以下为原文 Hi, I have not used the DMA yet and now looking at using it for Buffer to SPI and SPI to Buffer data transfer. For beginning, I thought of using the example code in Creator for 5LP. It appears straight forward but how is the transmission initiated in a real world example? Can I simply load data into txBuffer, wait till transfer complete and read results each time I want to transfer, like below? sprintf(txBuffer,"some data"); //put new data in tx Buffer while (0u == (SPIM_ReadTxStatus() & SPIM_STS_SPI_DONE)) { } //.wait till transferred for(i=0u; i LCD_PrintHexUint8(rxBuffer); //read received data } Thanks |
|
相关推荐
4个回答
|
|
在我的文章中,如何指定要为特定事务发送多少字节?
以上来自于百度翻译 以下为原文 Further to my Post, How do you specify how many bytes to send for any particular transaction? |
|
|
|
附件是我的项目连接F RAM到PSoC 3与DMA。这个项目是由PSoC Creator 3 SP1创建的。所以,我不知道最近的PSoC Creator是否可以使用。 您可以在GITHUB存储库中找到相同的项目:“GITHUB-NORANT/DIDE1163P03:使用SPI的FRAM测试项目” 数据长度似乎是由CydMatdStaseCuffic()API函数指定的。 //初始化DMA RX描述符 DMAIRXXCHANCH= DMAIXRXY主化( DMALRXYBYTEXPARIORB突发,DMAIRXXIQuestESTPARYBY突发, Hi16(DMA-RXX-SRCB基),Hi16(DMA-RXX-DSSTBASE) ; DMAYRXYTD〔0〕=CydMatalLoad(); CydMatdSt配置(DMAYRXYTD〔0〕, 味觉缓冲器 CythDMAXDISABLE TdIn CysDista ADR ; CydMatdStAdvices(DMAYRXYTD〔0〕, Lo16((UIT32)SPIMULRXDATAYPTR),Lo16((UIT32)MISoBuff.Fipe) ; CyDmaChSetInitialTd(DMAYRXXCHAN,DMAYRXYTD〔0〕); 当做, 诺里基 设计1163P033-MAST.ZIP 45.7 K 以上来自于百度翻译 以下为原文 Attached is my project connecting F-RAM to PSoC 3 with DMA. This project is created by PSoC Creator 3.0 SP1. So, I don't know if a recent PSoC Creator can be used. You can find the same project on my GitHub repository at "GitHub - noritan/Design116_3p0_3: F-RAM test project using SPI " It seems that the data length is specified by the CyDmaTdSetConfiguration() API function. // Initialize DMA RX descriptors DMA_RX_Chan = DMA_RX_DmaInitialize( DMA_RX_BYTES_PER_BURST, DMA_RX_REQUEST_PER_BURST, HI16(DMA_RX_SRC_BASE), HI16(DMA_RX_DST_BASE) ); DMA_RX_TD[0] = CyDmaTdAllocate(); CyDmaTdSetConfiguration(DMA_RX_TD[0], sizeof misoBuffer, CY_DMA_DISABLE_TD, TD_INC_DST_ADR | DMA_RX__TD_TERMOUT_EN ); CyDmaTdSetAddress(DMA_RX_TD[0], LO16((uint32)SPIM_RXDATA_PTR), LO16((uint32)misoBuffer.stream) ); CyDmaChSetInitialTd(DMA_RX_Chan, DMA_RX_TD[0]); Regards, Noriaki
|
|
|
|
numuwewr 发表于 2018-12-25 13:29 谢谢, 下面的工作会怎么样?在这里,我用新的NUMLUB重新发送DMA的每个调用来发送/接收。如果我重新初始化DMA每个调用,我仍然需要“CydMaStReVestRead(…)”函数吗? CysISR(DMAIRXXIN IOSISR){ DMAX RXX完成=1; } 空隙SPIWREST(UIT8字节){ TxBuff[ 0 ]=DAT0; TxBuff[ 1 ]=DAT1; TxBuff[ 2 ]=DAT2; dMNIT(NUMB); CyDmaChSetRequest(DMAI TXXCHAN,Cyth-DMAYCPURY-Req);???? /等待完成传输 而(!)DMAX RXX完成; } 空dMIIT(UIT8字节){ //初始化DMA TX描述符 DMAI- TXXCHANCH= DMAIXTXY主化 DMAIXTXYBYTEXPARYBY突发,DMAIXTXIQuestESTPARYBY突发, Hi16(DMA-TXX-SRCB基),Hi16(DMAI TXX-DSSTBASE) ; DMAY-TXYTD〔0〕=CydMatalLoad(); CydMatdSt配置(DMAIXTXYTD〔0〕, NuMnByb, CythDMAXDISABLE 蒂尔辛格尔斯达尔 ; CydMatdStAdvices(DMAIXTXYTD〔0〕, Lo16((UIT32)MsiPuffel.Sufl),Lo16((UIT32)SPIMUTXDATAYPTR) ; CyDmaChSetInitialTd(DMAI TXXCHAN,DMAY-TXYTD〔0〕); //初始化DMA RX描述符 DMAIRXXCHANCH= DMAIXRXY主化( DMALRXYBYTEXPARIORB突发,DMAIRXXIQuestESTPARYBY突发, Hi16(DMA-RXX-SRCB基),Hi16(DMA-RXX-DSSTBASE) ; DMAYRXYTD〔0〕=CydMatalLoad(); CydMatdSt配置(DMAYRXYTD〔0〕, NuMnByb, CythDMAXDISABLE TdIn CysDista ADR ; CydMatdStAdvices(DMAYRXYTD〔0〕, Lo16((UIT32)SPIMULRXDATAYPTR),Lo16((UIT32)MISoBuff.Fipe) ; CyDmaChSetInitialTd(DMAYRXXCHAN,DMAYRXYTD〔0〕); } 主回路 … SPIGREST(3); 对于(int i=0;i & lt;NuMbIL;I++) { 用RX缓冲区做某事 } … 以上来自于百度翻译 以下为原文 Thanks, Would something like below work? Where I re-init the dma each call with new numBytes to send/receive. Would I still need the "CyDmaChSetRequest(..." function if I am reinitializing the dma each call? CY_ISR(DMA_RX_INT_ISR) { DMA_RX_completed = 1; } void spiWrite(uint8 numBytes) { txBuffer[0] = dat0; txBuffer[1] = dat1; txBuffer[2] = dat2; dmaInit(numBytes); CyDmaChSetRequest(DMA_TX_Chan, CY_DMA_CPU_REQ); ??? // Wait for transfer completed while (!DMA_RX_completed) ; } void dmaInit(uint8 numBytes) { // Initialize DMA TX descriptors DMA_TX_Chan = DMA_TX_DmaInitialize( DMA_TX_BYTES_PER_BURST, DMA_TX_REQUEST_PER_BURST, HI16(DMA_TX_SRC_BASE), HI16(DMA_TX_DST_BASE) ); DMA_TX_TD[0] = CyDmaTdAllocate(); CyDmaTdSetConfiguration(DMA_TX_TD[0], numBytes, CY_DMA_DISABLE_TD, TD_INC_SRC_ADR ); CyDmaTdSetAddress(DMA_TX_TD[0], LO16((uint32)mosiBuffer.stream), LO16((uint32)SPIM_TXDATA_PTR) ); CyDmaChSetInitialTd(DMA_TX_Chan, DMA_TX_TD[0]); // Initialize DMA RX descriptors DMA_RX_Chan = DMA_RX_DmaInitialize( DMA_RX_BYTES_PER_BURST, DMA_RX_REQUEST_PER_BURST, HI16(DMA_RX_SRC_BASE), HI16(DMA_RX_DST_BASE) ); DMA_RX_TD[0] = CyDmaTdAllocate(); CyDmaTdSetConfiguration(DMA_RX_TD[0], numBytes, CY_DMA_DISABLE_TD, TD_INC_DST_ADR | DMA_RX__TD_TERMOUT_EN ); CyDmaTdSetAddress(DMA_RX_TD[0], LO16((uint32)SPIM_RXDATA_PTR), LO16((uint32)misoBuffer.stream) ); CyDmaChSetInitialTd(DMA_RX_Chan, DMA_RX_TD[0]); } Main Loop ... spiWrite(3); for(int i = 0; i < numBytes ; i++) { //do something with rxBuffer } ... |
|
|
|
hnui2002 发表于 2018-12-25 13:42 它需要调用CydMaStAdvestRead(DMAYTXXCHAN,CythDMAYCPURY-Req);在不初始化的情况下启动DMA传输。通过调用这个API,DMA将一个字节写入SPI数据寄存器,SPI启动传输序列。 此外,在启动DMA序列时,不要忘记启用DMA通道。 当做, 诺里基 以上来自于百度翻译 以下为原文 It is required to call CyDmaChSetRequest(DMA_TX_Chan, CY_DMA_CPU_REQ); to start a DMA transfer with or without initialization. By calling this API, the DMA writes a byte to the SPI data register and the SPI starts a transfer sequence. In addition, don't forget to enable the DMA channel when starting a DMA sequence. Regards, Noriaki |
|
|
|
只有小组成员才能发言,加入小组>>
753个成员聚集在这个小组
加入小组2092 浏览 1 评论
1838 浏览 1 评论
3658 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1779 浏览 6 评论
1528 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
538浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
397浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
426浏览 2评论
372浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
890浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-11 19:52 , Processed in 0.617908 second(s), Total 52, Slave 44 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号