1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
在我的应用程序中,我计划使用通用的Io管脚来模拟i2c……与我的i2c芯片(如PCF8574、ADS7828)通信……我已经成功地在一些C51系列单片机上实现了i2c,但我相信在微芯片上会有所不同,或者基本上,在PIC16F上可以做到吗?它将达到的最大速度是多少?对于I2c总线,我们需要io管脚作为开路漏极输出,但是在PIC16F上似乎不可能。但是我相信我们可以通过控制Io管脚的输入/输出方向来实现这一点:如果我们将管脚配置成输入,那么实际上在管脚输出上会出现高电平的输出,因为我们有定义为上拉电阻器的上拉电阻。根据I2c规范,如果我们想把引脚设置为低输出,我们可以把引脚设置为输出,写0,这是安全的,因为我们有上拉电阻。但是,如果我们把这个PIC的引脚设置为输出,写1,会发生什么呢?如果I2C芯片对应引脚设置为0,是否危险?在这种情况下,VCC将直接引导到地面??!如果有人能给出一些示例代码,那将是很大的帮助,谢谢!
以上来自于百度翻译 以下为原文 In my application,i'm planning to use general Io pins to simulate i2c...to communicate with my i2c chips like PCF8574,or ADS7828...; i've implemented i2c on some C51 series mcu successfully,but i believe it would be different on microchip,or basically,is it possible to do it on PIC16F? what is the max speed it will reach at? for I2c bus,we need io pins to act as open drain outputs,but seems impossible on PIC16F. but i believe we could do it by controlling Io pins input/output directions:if we configure the pin as input,actually high level ouput will appear on the pin's out ,since we have pull-up resistors which is defined by I2c spec;if we want to set pin to low output,we can set ths pin as output,and write 0,it is safe because we have pull up resistor. but what will happen if we set this PIC's pin as output,and write 1? is it dangerious if i2c chips corresponding pin setting to 0?under this situation,the VCC will direct led to ground??! it will be great help if anyone could give some example code,thanks in advance! Attached Image(s) |
|
相关推荐
6个回答
|
|
请参阅下面的应用说明,其中包括在PIC16.AN544上实现软件中的I2C主机。
以上来自于百度翻译 以下为原文 See the below Application Note which cover implementing a I2C master in software on a PIC16. AN554. . |
|
|
|
请参阅此线程:HTTP://www. McCHIP.COM/FUMMS/M935595.ASPX
以上来自于百度翻译 以下为原文 See this thread: http://www.microchip.com/forums/m939595.aspx |
|
|
|
当然有可能,上面提到的应用程序注释应该会有帮助。回答你的具体问题:根据你以什么速度计时PIC,应该很容易实现100kHz的操作,如果你是一个高效的程序员,甚至400kHz。延迟一个开放式收集器输出。通常的方法是将零写入数据位,并根据需要旋转方向位。你不应该这样做,因为正如你所提到的,总线上的另一个设备可能试图将引脚压低。很难弄清楚你在这里想要说什么。如前所述,不要把PIC管脚开得太高。在旧的PIC16F设备(即,不是更新的PIC16F1xx设备)上这样做需要小心,因为它们没有LATx寄存器。这意味着,由于众所周知的读-修改-写效应,如果在与仿真I2C管脚相同的端口中的另一个管脚上使用BSF或BCF instruciton,则会冒意外地将数据位从0更改为1的风险。
以上来自于百度翻译 以下为原文 It's certainly possible, the app notes referenced above should help. Answering your specific questions: Depending upon what speed you are clocking the PIC at, it should be easy to achieve 100kHz operation, and even 400kHz if you're an efficient programmer. Indeed, this is a well known technique to emulate an open-collector output. The usual technique it so write a zero to the data bit, and just twiddle the direction bit as required. You should not do that, because as you mention, another device on the bus may be trying to drive the pin low. It's hard to work out what you are trying to say here. As already said, do NOT drive the PIC pin high. You DO need to be careful doing this on an old PIC16F device (i.e. not the newer PIC16F1xxx devices) because they do not have LATx registers. That means because of the well known read-modify-write effect, if you use a BSF or BCF instruciton on another pin in the same port as your emulated I2C pins, you run the risk of accidentally changing your data bit from a 0 to a 1. |
|
|
|
谢谢猴腺酱,但是我认为AN554是旧的(1997),事实上它是在汇编语言中构建的,但是仍然非常有用。Danno,线程:我们几乎谈论了我担心的事情,非常有用,谢谢!感谢您的详细回复!我会仔细研磨我的代码……看看我们能否达到400KHz,我的XC8是空闲模式,CPU OSC=16MHz或8MHz(源自内部OSC),但我认为这不是问题。我看到很多样本是在汇编器中,这次我想用C语言,幸运的是,我使用了PIC145X,增强的中间范围8位的新产品,我想知道微芯片什么时候推出……PIC145X现在是我想要的:低引脚数(采样尺寸),低成本,但是gess…你还有USB,外部OSC不必要(由于ACT),一切都足够,但是不浪费。如果有机会,我也会尝试PIC18F1XK50。顺便说一下,PIC16F1454是e。全世界都能买到吗?
以上来自于百度翻译 以下为原文 Thanks monkey_gland_sauce,but i think AN554 is old(1997),in fact it was built in assembler,but still very useful. Danno,the thread: ws almost talking the same thing i was worrying,very helpful,Thanks! qhb, Thanks for your detailed replies!I will carefully polish my code......to see if we could reach at 400KHz,my XC8 is in free mode and CPU OSC=16MHz or 8MHz(derived from interal OSC) ,but i think that is not a question. I saw many samples was in assembler,I would like to use C languange this time,fortunately, i use PIC145X,Enhanced mid-range 8bits new product,i wonder what time Microchip pushed them out...PIC145X is now what i want:low pin count(samll size),low cost,but gess what...you still get USB,external OSC unnecessry(due to ACT);everything is enough but no waste. i will also try PIC18F1XK50 if any chance. BTW,PIC16F1454 is easy to buy all over the world? |
|
|
|
PIC16F1454应该在任何地方都可用。我的主要问题是,如果这个设备已经具有I2C引擎,为什么还要尝试模拟I2C?AN734有助于在C.实施I2C
以上来自于百度翻译 以下为原文 PIC16F1454 should be available anywhere. My main question is why are you trying to emulate an I2C if this device already has an I2C engine? AN734 is helpful in implementing I2C in C. |
|
|
|
主要原因是,1454个l2c引脚与闪烁引脚重复,难以调试;现在我已改为pic16f1459,利用mssp的i2c主机…
以上来自于百度翻译 以下为原文 main reason is that 1454 l2c pins are duplicated with flashing pins,hard to debug; now i have changed to pic16f1459 taking advantage of mssp i2c master... |
|
|
|
只有小组成员才能发言,加入小组>>
5237 浏览 9 评论
2027 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3202 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
772浏览 1评论
662浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
590浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
672浏览 0评论
572浏览 0评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-21 20:42 , Processed in 1.244197 second(s), Total 86, Slave 70 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号