完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我使用的是使用MCC(MPLAB代码配置器)的PIC16LF18325。我在MSSP2上使用它们,所以我已经将RC4设置为sCLK2和RC1作为SDA2。由于某些原因,当我进行masterWrite或masterRead时,这些管脚没有任何输出。以下是pin_manager.cLATA=0x0;LATC=0x0;WPUA=0x0;WPUC=0x0;ANSELA=0x37;ANSELC=0x5;TRISC=0x38;TRISA=0x13;以及RC1PPSbits.RC1PPSbits=0x1B;//RC1-RC1-1MSSP2:SDA2;SSP1DATPPS位.SSP1P1DATPPS位.SSP1DATPPS=0x15;//RC5->/RC5->;MSSP1:MSSP1:SDI1;MSSP1:RSSP1:SDSP1:SDI1;RC4 RC4PPS位.RC4 RC4PPS位.RC4PPS=0x1A=0x1A;//RC4->/RC4->;MSSP2:SCSP2:SCL2:SCL2;RC0PPS位.RC0PPS位RC0PPS RC0PPS位.RC0PPS=RC0PPS=0X18;RCSP1:RCSP1:RCSP1:SC0SC0PPS=0X18;//SSP2DATPPS=0x11;//RC1->MSSP2:SDA2;SSP2CLKPPSbits.SSP2CLKPPS=0x14;//RC4->MSSP2:SCL2;RA5PPSbits.RA5PPS=0x14;//RA5->EUSART:TX;PPSLOCK=0x55;PPSLOCK=0xAA;PPSLOCKbits.PPSLOCKED=0x01;//lock PPSGIE=state;这些值对于成功的I2C通信正确吗?如果是的话,我使用I2C MCC函数时肯定有问题。
以上来自于百度翻译 以下为原文 I am using a PIC16LF18325 using MCC (mplab code configurator). I am using them on MSSP2 so I have set RC4 as SCLK2 and RC1 as SDA2. For some reason there is nothing coming out of those pins when I do a masterWrite or masterRead. Here are the relevant registers in the pin_manager.c LATA = 0x0; LATC = 0x0; WPUA = 0x0; WPUC = 0x0; ANSELA = 0x37; ANSELC = 0x5; TRISC = 0x38; TRISA = 0x13; and further on: RC1PPSbits.RC1PPS = 0x1B; //RC1->MSSP2:SDA2; SSP1DATPPSbits.SSP1DATPPS = 0x15; //RC5->MSSP1:SDI1; RC4PPSbits.RC4PPS = 0x1A; //RC4->MSSP2:SCL2; RC0PPSbits.RC0PPS = 0x18; //RC0->MSSP1:SCK1; RC2PPSbits.RC2PPS = 0x19; //RC2->MSSP1:SDO1; SSP2DATPPSbits.SSP2DATPPS = 0x11; //RC1->MSSP2:SDA2; SSP2CLKPPSbits.SSP2CLKPPS = 0x14; //RC4->MSSP2:SCL2; RA5PPSbits.RA5PPS = 0x14; //RA5->EUSART:TX; PPSLOCK = 0x55; PPSLOCK = 0xAA; PPSLOCKbits.PPSLOCKED = 0x01; // lock PPS GIE = state; Are these values correct for successful I2C communication? If they are, there must be something wrong with how I am using the I2C MCC functions. |
|
相关推荐
5个回答
|
|
这里是我的I2C寄存器的信息:SSP2CON1= 0x28 SSP2CON3=0x00 SSP2ADAD= 0x03SSP2STAT=0x00
以上来自于百度翻译 以下为原文 Here is info on my I2C registers: SSP2CON1 = 0x28 SSP2CON3 = 0x00 SSP2ADD = 0x03 SSP2STAT = 0x00 |
|
|
|
请重新评估您的TRISC配置。TRISC=0x38;(RC1/SDA2=OUTPUT,RC4/SCL2=INPUT)尝试将RC1设置为输入。用户应该通过设置适当的TIIS位来设置输入。DS400 01795B页324
以上来自于百度翻译 以下为原文 Please reevaluate your TRISC configuration. TRISC = 0x38; (RC1/SDA2 = OUTPUT, RC4/SCL2 = INPUT) Try setting RC1 as an input. TRISC = 0x3A; 29.4.3 SDA AND SCL PINS Selection of any I2C mode with the SSPEN bit set, forces the SCL and SDA pins to be open-drain. These pins should be set by the user to inputs by setting the appropriate TRIS bits. DS40001795B-page 324 |
|
|
|
这似乎有点帮助。还有其他需要调整的寄存器吗?我至少在时钟/数据线中有一个摆动,但从图片上可以看出,时钟线看起来像完全垃圾。你知道为什么会这样吗?在图片中,蓝色的轨迹是时钟,紫色的痕迹是数据。我给地址发送了0B1011100,这似乎是正确的。
以上来自于百度翻译 以下为原文 This appeared to have helped a little. Are there any other registers you see that need an adjustment? I at least got a wiggle in the clock/data lines but as you can see from the picture, the clock line looks like complete crap. Any idea why this might be? In the picture the Blue trace is the clock and the Purple trace is the data. I am sending 0b1011100 for the address, which appears to be correct. Attached Image(s) |
|
|
|
请不要在3个不同的线程中继续讨论这个主题。
以上来自于百度翻译 以下为原文 Please do not continue to discuss this topic in 3 different threads. See my comment in http://www.microchip.com/forums/m942552.aspx#942902 |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5136 浏览 9 评论
1987 浏览 8 评论
1917 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3155 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2215 浏览 5 评论
702浏览 1评论
593浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
476浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
608浏览 0评论
500浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-5 18:21 , Processed in 1.412236 second(s), Total 86, Slave 69 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号