完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,我目前正在工作的I2C连接读取感官数据从MPU6050传感器(奴隶)。硬件和软件:MPLABX V3.55与XC16 V1.31编译器资源管理器16 EVAL。带有PIC24FJ128GA010(32 MHz)微芯片(主控)逻辑分析仪的遗留外围设备LabroRabyPU6050传感器(用3.3VSDA1和SCL1(PIN RG3和RG2)提供)通过2.2 kOHM被拔出,我与I2C连接的问题是,每当发送开始信号(I2C1CONBITSS.SEN=1)时从主设备,主总线冲突检测位(I2C1STATBITS.BCL)设置为1。此外,程序总是会在瞬间出现(!)在第46行调用FrlStaseWrraveI2C1((Read EddiSRICS&L.&L.;1))之后,IFS1BIT.MI2C1IF行(ththaWaistFrand())函数,这是第一个问题的结果。重要的是要知道,SCL1和SDA1都是高的开始-必须是空闲状态,应该是好的。但我看不到一个典型的时钟行为或任何其他变化(只是一个恒定的高电压)。我已经很快地改变了I2C引脚的位状态,然后在逻辑分析仪软件上显示,所以线连接也应该是好的。奇怪的是,整个设置在几天前运行得很好。逻辑分析仪能够分析和可视化我发送的每一个命令。我也能够显示温度和加速度数据从传感器上的LCD的评估板。我没有改变硬件,也没有改变软件里面的东西。因此,从属和所有其他寄存器命令的I2C地址必须是正确的。因为我经常改变MPLAB中的项目,我猜想我可能已经改变了PIC微控制器的配置位(我也改变了,但没有成功)或其他配置现在是S。在PIC的某个地方,如果有人能帮我的话,那真是太棒了!附有程序的ZIP文件夹!非常感谢!问候语
以上来自于百度翻译 以下为原文 Hello guys, I am currently working on an i2c connection to read sensory data out from the MPU6050 sensor (slave). Hardware & software:
What's really strange is, that the whole setup worked well few days ago. The logic analyzer was able to analyze and visualize every command which I sent. I was also able to display the temperature and the acceleration data from the sensor on the LCD of the evaluation board.. I didnt't change the hardware and neither did I change something within the software. So the i2c address of the slave and all the other register commands have to be ok. Since I changed projects in MPLAB quite often, my guess is that I might have changed the configuration bits of the pic microcontroller (which I also changed but without success) or other configurations which are now stored somewhere in the pic. It would be really great if someone could help me with tha!! The zip folder with the programm is attached! Thank you so much! Greetings Attachment(s) I2Ctestv1.0.X.zip (102.05 KB) - downloaded 73 times |
|
相关推荐
11个回答
|
|
没有看你的来源,但你首先要检查的是I2C引脚是否具有模拟能力,如果是,请确保它们被切换到数字模式。
以上来自于百度翻译 以下为原文 Haven't looked at your source, but the first thing you should check is if the I2C pins have analog capability, and if so, make sure they are switched to digital mode. |
|
|
|
谢谢QHB的回答!我已经检查过PIN是类似的还是数字的,但是C的SDA1和SCL1引脚不支持类似的功能。我现在尝试通过MCC与传感器通信,但是我得到了相同的结果。顺便说一下,我用ICD3作为调试器,我忘了在我的第一篇文章中提到。BCL中断标志总是在启动条件下设置,逻辑分析仪对于SDA和SCL都保持高电平。
以上来自于百度翻译 以下为原文 Thank you qhb for your answer! I already checked if the pins are analoge or digital, but the SDA1 and SCL1 pins of the µC don't support an analoge functioning. I tried now to communicate with the sensor via MCC but I got the same result.. BTW I am using ICD3 to as a debugger, which I forgot to mention in my first post. The BCL interrupt flag is always set after a start condition and the logic analyzer stays high for both SDA and SCL.. |
|
|
|
您是否确保了9050的I2C地址引脚不是浮动的?
以上来自于百度翻译 以下为原文 Did you ensure that the Invensense 9050 i2c address pin is not floating? |
|
|
|
传感器的销钉不是浮动的。我尝试了一个新的项目,只初始化I2C模块并手动设置启动条件,但也遇到了同样的问题。看起来这个配置好像有问题。传感器工作正常,我现在用ARDUNO测试了它。我可以尝试I2C2模块,而不是MODUL 1,尽管它昨天运行良好。附加了BCL标志,它总是在STARTI2C1()之后设置,以及逻辑分析仪屏幕截图,在那里你可以看到两条通信线都很高。
以上来自于百度翻译 以下为原文 The sensor's adress pin is not floating. I tried making a new project with only initialising the i2c modul and setting a start condition manually but got the same problem. It really seems like there is something wrong with the configuration. The sensor works fine, i tested it with an arduino right now. I could try the i2c2 modul instead of modul 1 even though it worked fine til yesterday. Attached the BCL flag which is always set after the StartI2C1() instruction as well as the logic analyzer screenshot where you can see that both communicatin lines are just high. Attached Image(s) |
|
|
|
嗯,如果你说它与昨天的代码完全相同,并且传感器没有损坏,那么它应该工作。因为它不起作用,一些假设肯定是错误的。我认为Bcl最有可能的原因是PIC不能控制SDA线。例如,如果你把传感器从SDA线断开,我希望你能再次看到你的SaleAE逻辑分析仪上的时钟。如果不是,则源代码需要更仔细的查看。确保代码从BCL重置开始。用另一个I2C2进行测试总是值得测试的,尤其是因为您已经说过代码已经工作过。
以上来自于百度翻译 以下为原文 Hm, if you say it worked with exactly the same code yesterday, and the sensor is not damaged, then it should work. Since it does not work, some assumption must be wrong. I think the most likely reason for BCL is that the PIC cannot control the SDA line. E.g. if you disconnect the sensor from your SDA line, I would expect that you again can see the clock on your Saleae Logic Analyzer. If not, the source code needs a more close look. Be sure that your code starts with BCL reset. Doing a test with the other i2c2 is always worth a test, especially since you said, the code already worked before. |
|
|
|
如果PIC外部的I2C信号线是高逻辑电平,如逻辑分析仪所示,问题将在PIC内部。在IN C调试器中,I2C信号引脚的端口寄存器位都是1,在I2C初始化之前和在启动条件之前都是。TART条件信令已完成,I2C端口信号位应为0,状态寄存器S位应为1,BCL位应清晰。如果不发生,则无进展。Mysil
以上来自于百度翻译 以下为原文 Well, if the I2C signal lines outside the PIC are High logic level, as indicated by the logic analyzer, the problem would be inside the PIC. Check in debugger that PORT register bits for the I2C signal pins are both 1, both before I2C is Initialized, and before enabling the Start condition. Then after Start condition signaling is completed, both I2C PORT signal bits should be 0, Status register S bit should be 1, and BCL bit shall be clear. If this do not happen, then there is no point in proceeding. Regards, Mysil |
|
|
|
嘿,Mysil,谢谢你的回复。我不知道这是否正常,但是我不能在初始化I2C模式之前设置PurgBist.RG3到1——它从一开始就设置为低。这个引脚是SDA数据线的一个引脚。SCL1管脚一直很高。我不能通过编写PoxGbj.Rg3=1来改变这个PIN的状态;除了LGGBITS.RG3设置为1而不是PORTG寄存器,没有发生任何事情…所以我的I2C连接不再工作了,你知道我怎么能把这个引脚设置为1吗?我将JTAGEN设置为配置位中的OFF状态,因为我在互联网上看到这也可能是一个问题。
以上来自于百度翻译 以下为原文 Hey Mysil, thank you for your reply. I don't know if this is normal but I can't set the PORTGbits.RG3 to 1 before initializing the i2c modue - it is set to low right from the beginning. This PIN is the one for the SDA data line. The SCL1 PIN is high all the time. I can not change the state of this pin by just writing PORTGbits.RG3 = 1; Nothing happens except that the LATGbits.RG3 sets to 1 instead of the PORTG register... So there has to be the problem why my i2c connection is not working anymore. Do you know how I can set this PIN to 1? I set JTAGEN to OFF state in the configuration bits because I read in the internet that this could also be a problem.. Kind regards Mark |
|
|
|
这里是一个图片的PORTG寄存器和LATG寄存器!
以上来自于百度翻译 以下为原文 Here is a picture of the PORTG register and the LATG register! Attached Image(s) |
|
|
|
总是写到LATx,如果PIN被设置为输出,也将在PORTx设置相应的PIN,但不存在读取修改写入风险的风险。
以上来自于百度翻译 以下为原文 Always write to LATx which, if the pin is set as output, will also set the corresponding pin in PORTx - but without the risk of Read-Modify-Write effect |
|
|
|
对于使用I2C,我必须设置这些引脚作为输入引脚,所以TRISG寄存器被定义为这些引脚的输入。但是,如果我把它定义为一个输出,正如你提到的,并写入到LATG寄存器,结果与我之前的结果相同——只有引脚RG2设置为1,PIN RG3(SDA1)不能设置为0到1:
以上来自于百度翻译 以下为原文 For using i2c I have to set these pins as Input PINs so the TRISG register is defined as an input for these PINs. But if I define it as an output as you mentioned and write to the LATG register, the result is the same as in my post before - only PIN RG2 is set to 1, PIN RG3 (SDA1) can't be set from 0 to 1 :/ |
|
|
|
嘿,伙计们,我又成功了!代码在运行,我没有改变它里面的任何东西。所以,如果你想下载它是免费的,它正在工作。问题是,C的RG3 PIN受到某种程度的损坏,我认为,或其他事情发生在C,所以我不能把这个引脚高(看附件)。LATG完全设置为1,PoG的所有引脚也设置为1,除了SDA数据线RG3所需要的一个。我现在使用的另一个I2C模块的同一个PIC与RA2和RA3 PIN的SCL2和SDA2,一切都很好。谢谢你花一点时间,帮助我。祝你周末愉快!亲切问候
以上来自于百度翻译 以下为原文 Hey guys, I managed to get it working again!! The Code is functioning and I did not change anything in it. So if you want to download it feel free, it is working. The problem was that the RG3 Pin of the µC got somehow damaged I think, or something else happend within the µC so that I was not able to set this Pin to high (look at the attached files). LATG was completely set to 1 and all of the PINs from PORTG were also set to 1 except the one I needed for the SDA data line RG3. I use now the other i2c module of the same pic with RA2 and RA3 PIN for SCL2 and SDA2 and everything works fine. Thank you for taking a time and helping me. I wish you a pleasant weekend! Kind regards Attached Image(s) |
|
|
|
只有小组成员才能发言,加入小组>>
5242 浏览 9 评论
2031 浏览 8 评论
1955 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3207 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2256 浏览 5 评论
778浏览 1评论
669浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
596浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
678浏览 0评论
577浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 20:02 , Processed in 1.758215 second(s), Total 65, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号