完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
背景:MPLAB X IDE V4.15,XC32 V2.05,和声V2.05,PIC32 MZ2048 EFH100也许我不正确地接近,但是这是我正在尝试做的。一个板被设计成与BM770用最少的针来进行工作。由于没有开关,用户可以直接与BM91开发板直接对话,所以我不得不通过PIC。幸运的是,板上有一个用于USB到USAT CMS的FTDI芯片。我试图做的是:使用DMA(下面的代码)将UTART与FTDI芯片的接口连接到BM91模块的接口。这不起作用,我不太清楚为什么。我经常使用DMA,并且已经阅读了它的部分手册,虽然我不熟悉所有可用的选项,因为我不需要它们。我所做的是让一个UART的接收器成为DMA信道的源,另一个作为目的地的发射器。另外,源、目的地和单元大小都设置为1。自动启用设置。这种想法是,如果一个字节被接收,一个中断被触发,它被发送到发射机,DMA通道重置并再次在同一个地点开始。基本上,我试着通过PIC从一个UART到另一个隧道,而不需要CPU。看起来这应该是可行的。我想我可以看看频道链接,是的,我可以用中断来做。不过,使用DMA对我更有吸引力。
以上来自于百度翻译 以下为原文 Background: MPLAB X IDE v4.15, XC32 v2.05, HARMony v2.05, PIC32MZ2048EFH100 Perhaps I'm approaching this incorrectly, but here is what I'm trying to do. A board was designed to talk to a BM71 with the minimum set of pins needed to make that work. Since there is no switch, such that the user can talk to the module directly like the BM71 development board, I'm forced to go through the PIC. Fortunately, there is an FTDI chip on the board for USB to USART comms. What I attempted to do was this: connect the UART that interfaces with the FTDI chip to that of the BM71 module using DMA (code below). It doesn't work and I'm not exactly sure why. I use DMA frequently, and have read the section manual on it, though I'm unfamiliar with all of the options available as I haven't needed them. What I did was make one UART's receiver the source of a DMA channel and the transmitter of another as the destination. Additionally, source, destination, and cell size are all set for 1. Auto-enable is set as well. The thinking being that if a byte is received, an interrupt is triggered, it's sent to the transmitter and the DMA channel resets and starts again in the same spot. Basically, I'm trying to tunnel from one UART to another through the PIC without the need for the CPU. It really seems like this should work. I suppose I can look into channel chaining and, yes, I can do this with interrupts. Using DMA is more appealing to me, though. PLIB_USART_Disable(USART_ID_1); PLIB_USART_HandshakeModeSelect(USART_ID_1, USART_HANDSHAKE_MODE_SIMPLEX); PLIB_USART_InitializeModeGeneral(USART_ID_1, false, false, false, false, false); PLIB_USART_LineControlModeSelect(USART_ID_1, USART_8N1); PLIB_USART_OperationModeSelect(USART_ID_1, USART_ENABLE_TX_RX_USED); PLIB_USART_ReceiverInterruptModeSelect(USART_ID_1, USART_RECEIVE_FIFO_ONE_CHAR); PLIB_USART_TransmitterInterruptModeSelect(USART_ID_1, USART_TRANSMIT_FIFO_NOT_FULL); PLIB_USART_BaudSetAndEnable(USART_ID_1, SYS_CLK_BUS_PERIPHERAL_1, 115200); PLIB_USART_Disable(USART_ID_6); PLIB_USART_HandshakeModeSelect(USART_ID_6, USART_HANDSHAKE_MODE_SIMPLEX); PLIB_USART_InitializeModeGeneral(USART_ID_6, false, false, false, false, false); PLIB_USART_LineControlModeSelect(USART_ID_6, USART_8N1); PLIB_USART_OperationModeSelect(USART_ID_6, USART_ENABLE_TX_RX_USED); PLIB_USART_ReceiverInterruptModeSelect(USART_ID_6, USART_RECEIVE_FIFO_ONE_CHAR); PLIB_USART_TransmitterInterruptModeSelect(USART_ID_6, USART_TRANSMIT_FIFO_NOT_FULL); PLIB_USART_BaudSetAndEnable(USART_ID_6, SYS_CLK_BUS_PERIPHERAL_1, 115200); PLIB_DMA_ChannelXStartIRQSet(DMA_ID_0, DMA_CHANNEL_0, DMA_TRIGGER_USART_1_RECEIVE); PLIB_DMA_ChannelXTriggerEnable(DMA_ID_0, DMA_CHANNEL_0, DMA_CHANNEL_TRIGGER_TRANSFER_START); PLIB_DMA_ChannelXPrioritySelect(DMA_ID_0, DMA_CHANNEL_0, DMA_CHANNEL_PRIORITY_3); PLIB_DMA_ChannelXSourceStartAddressSet(DMA_ID_0, DMA_CHANNEL_0, KVA_TO_PA((void *)U1RXREG)); PLIB_DMA_ChannelXDestinationStartAddressSet(DMA_ID_0, DMA_CHANNEL_0, KVA_TO_PA((void *)U6TXREG)); PLIB_DMA_ChannelXSourceSizeSet(DMA_ID_0, DMA_CHANNEL_0, 1); PLIB_DMA_ChannelXDestinationSizeSet(DMA_ID_0, DMA_CHANNEL_0, 1); PLIB_DMA_ChannelXCellSizeSet(DMA_ID_0, DMA_CHANNEL_0, 1); PLIB_DMA_ChannelXAutoEnable(DMA_ID_0, DMA_CHANNEL_0); PLIB_DMA_ChannelXEnable(DMA_ID_0, DMA_CHANNEL_0); PLIB_DMA_ChannelXStartIRQSet(DMA_ID_0, DMA_CHANNEL_4, DMA_TRIGGER_USART_6_RECEIVE); PLIB_DMA_ChannelXTriggerEnable(DMA_ID_0, DMA_CHANNEL_4, DMA_CHANNEL_TRIGGER_TRANSFER_START); PLIB_DMA_ChannelXPrioritySelect(DMA_ID_0, DMA_CHANNEL_4, DMA_CHANNEL_PRIORITY_3); PLIB_DMA_ChannelXSourceStartAddressSet(DMA_ID_0, DMA_CHANNEL_4, KVA_TO_PA((void *)U6RXREG)); PLIB_DMA_ChannelXDestinationStartAddressSet(DMA_ID_0, DMA_CHANNEL_4, KVA_TO_PA((void *)U1TXREG)); PLIB_DMA_ChannelXSourceSizeSet(DMA_ID_0, DMA_CHANNEL_4, 1); PLIB_DMA_ChannelXDestinationSizeSet(DMA_ID_0, DMA_CHANNEL_4, 1); PLIB_DMA_ChannelXCellSizeSet(DMA_ID_0, DMA_CHANNEL_4, 1); PLIB_DMA_ChannelXAutoEnable(DMA_ID_0, DMA_CHANNEL_4); PLIB_DMA_ChannelXEnable(DMA_ID_0, DMA_CHANNEL_4); |
|
相关推荐
1个回答
|
|
呸!忘记接收RX/TX寄存器的地址。现在测试。编辑:是的,我是白痴。它起作用了。
以上来自于百度翻译 以下为原文 DOH! Forgot to take the addresses of the RX/TX registers. Testing that now. Edit: Yep, I'm a moron. It works. |
|
|
|
只有小组成员才能发言,加入小组>>
5161 浏览 9 评论
1999 浏览 8 评论
1928 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3171 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2226 浏览 5 评论
731浏览 1评论
613浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
503浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
629浏览 0评论
527浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 23:04 , Processed in 1.234242 second(s), Total 77, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号