1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,朋友们,我在PIC16LF1939上工作。我使用SPI与另一个微控制器通信,我必须使用I2C协议来发光LED,因为PIC16LF1939只有一个MSSP,我们如何同时实现两者?请让我知道,如果可能的话,举一个C代码的例子来实现它。谢谢和问候,Sarvanan。
以上来自于百度翻译 以下为原文 Hi Friends, I am working on PIC16LF1939. I am using spi to communicate with another microcontroller. I have to use I2c protocol to glow the LED's. As PIC16LF1939 has only one MSSP how can we achieve both at the same time? Please let me know and if possible give an example in 'C' code to achieve it. Thanks & regards, Sarvanan. |
|
相关推荐
11个回答
|
|
使用HW模块进行SPI(更快),并在其他2PIN中实现软件I2C(BIT Butd)
以上来自于百度翻译 以下为原文 Use the HW module for SPI (faster) and implement I2C in software (bit-banged) on any other 2pins |
|
|
|
嗨,辛齐格,谢谢你的邮件。我想照你的建议去做。SPI使用MSPP和I2C使用PIN。请你给我举一个XC8编译器的例子,其中两个都是用上面的想法完成的。我使用PIC16LF1939。谢谢,问候,Sarvanan。
以上来自于百度翻译 以下为原文 Hi CinziaG, Thanks for the mail. I want to do the same as you suggested. SPI using MSSP and I2c using pins. Could you please point me an example for xc8 compiler where both are done using the above idea? I am using PIC16LF1939. Thanks & regards, Sarvanan. |
|
|
|
我发布了我通常在这里使用的代码:HTTP://www. McCHIP.COM/FUMMS/FUNDPOST/949090HTH…
以上来自于百度翻译 以下为原文 I published the code I usually use in here: http://www.microchip.com/forums/FindPost/994790 HTH ... |
|
|
|
嗨,ChanZig,谢谢你的邮件和提供代码。如果我遇到任何问题,我会尽力回复你。再次感谢。Sarvanan。
以上来自于百度翻译 以下为原文 Hi CinziaG, Thanks for the mail and providing the code. I will try and get back to you if I face any issue. Many thanks again. With regards, Sarvanan. |
|
|
|
|
|
|
|
嗨,两个同时可能是困难的,但是一次一个地交替,可能是尴尬的。你可以禁用MSSP模块,当SPI或I2C传输已经完成时,就像最初设置时一样改变控制寄存器,并启用新模式中的模块。SPI设备,所有的都有自己的芯片选择信号,所以只要CS不活动,其他SPI线路上的信令就不重要了。然而,I2C将是个问题。I2C奴隶会被I2C信号线上的随机信令弄糊涂,而你所拥有的设备没有MSP信号引脚的PPS或APFCON。由于I2C信令对SDA和SCL信号都是双向的,所以门控I2C信号线有点复杂。存在开关/中继器/为I2C信号设计的隔离器/驱动器/电平转换器,其中一些有能力禁用通信的一侧。在每一个信号线上使用一个MOSFET晶体管,在不同的上拉电压电平之间进行I2C电平转换的设计。也许也可以用0 V门电压。关于,Mysil
以上来自于百度翻译 以下为原文 Hi, Both at the same time may be difficult, but alternating one at a time, may be possible, although awkward. You may disable the MSSP module, when a SPI or I2C transfer have been completed, change control registers just as when initially setting up, and enable the module in the new mode. SPI devices, all have their own Chip select signal, so as long as CS is inactive, signalling on the other SPI lines do not matter. I2C however, will be problematic. I2C slaves will get confused by random signalling on the I2C signal lines, and the device you have, doesn't have PPS or APFCON for MSSP signal pins. Since I2C signalling is bidirectional for both SDA and SCL signals, gating I2C signal lines is a little complicated. There exists switches / repeaters / isolators / drivers / level translators, designed for I2C signals, some of those have the ability to disable one side of the communication. There is a design for I2C level translation between different pull-up voltage levels, using a single MOSFET transistor for each signal line. Maybe that could also be used with 0 V gate voltage. Regards, Mysil |
|
|
|
我在一个接口上做了这两个接口,但是我不推荐它。你必须把两个接口都敲击一下,以确保SPI信令永远不会产生I2C启动条件。我会用ChanZIa的建议,SPI的硬件,和单独的引脚上的I2C位Bog。
以上来自于百度翻译 以下为原文 I've done both on the one interface, but I wouldn't recommend it. You have to bit-bang both interfaces to make sure the SPI signalling never generates an I2C START condition. I'd go with Cinzia's suggestion, hardware for SPI, and bit bang for I2C on separate pins. |
|
|
|
两种选择。切换到具有16MS1829或16F1947的设备,该设备具有2个MSSP模块。另一个选项是切换到具有PPS的设备。I2C引脚是固定的,但您可以移动SPI引脚到另一个位置。您将需要禁用和重新启用每种模式。大多数新的16F16xx,16F17XX,16F188XX部件都有PPS,应该工作。
以上来自于百度翻译 以下为原文 Two options. Switch to a device like the 16F1829 or the 16F1947 that have 2 MSSP modules. The other option is to switch to a device that has PPS. The I2C pins are fixed but you can move the SPI pins to another position. You will need to disable and re enable each mode. Most of the new 16F16XX, 16F17XX, 16F188XX parts have PPS and should work. |
|
|
|
好笑。除非我需要SPI上的高速,否则我会猛击它。更容易咬住SPI。
以上来自于百度翻译 以下为原文 Funny. Unless I needed high speed on the SPI, I would bit bang that. It is much easier to Bit Bang SPI. |
|
|
|
同意,但你更可能需要高速的SPI比I2C。
以上来自于百度翻译 以下为原文 Agreed, but you're more likely to require high speed on SPI than I2C. |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5255 浏览 9 评论
2038 浏览 8 评论
1958 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3219 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2268 浏览 5 评论
796浏览 1评论
689浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
618浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
687浏览 0评论
587浏览 0评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-31 02:33 , Processed in 1.586255 second(s), Total 96, Slave 80 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号