完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
朋友们,在参考了大量关于在IIC主模式下使用MSSP的信息之后,我做了以下工作:SSP1CON1=0x28;//MSSP Enable as IIC Master at FOSC/4SSP1CON2=0x00;SSP1ADD=0x28;//设置I2C地址,设置IIC总线为100kHzSSP1STAT=0x80;//SSPSTAT=0;//也进行了尝试,但是没有查找nge...问题仍然是sameTRISB4=1;TRISB6=1;SEN=1;//此时SEN位变为“1”延迟(100);//在小延迟之后,SEN位变为“0”,目前为止还不错//但是SDA(RB4)和SCL(RB6)管脚上没有活动……我在DSO.SSP1BUF=0xAA上检查了它;//没有看到SIC和SCL引脚的IIC,这两个引脚是什么高可能是错误的?我正在使用XC8编译器。谢谢。Kiran V Sutar
以上来自于百度翻译 以下为原文 Friends, After referring to tonnes of information about using MSSP in IIC Master Mode, I did the following: SSP1CON1 = 0x28; // MSSP Enable as IIC Master at FOSC/4 SSP1CON2 = 0x00; SSP1ADD = 0x28; // Set I2C address, Set IIC Bus for 100 kHz SSP1STAT = 0x80; // SSPSTAT = 0; // Tried this also, but No change...problem remains the same TRISB4 = 1; TRISB6 = 1; SEN=1; // At this point the SEN bit becomes "1" Delay (100); // After the small Delay the SEN bit becomes "0" So far so good // But there is NO activity on the SDA(RB4) and SCL(RB6) pins...I checked it on the DSO. SSP1BUF=0xAA; // Nothing seen on the SDA and SCL pins of IIC, both pins are HIGH What could be wrong? I am using XC8 compiler. Thanks in advance. Kiran V Sutar |
|
相关推荐
3个回答
|
|
|
|
|
|
注意,您的两个注释是错误的,应该是:并且还要注意,如果您的时钟是16MHz,那么SSP1ADD应该是39,也就是0x27,以获得100kHz。
以上来自于百度翻译 以下为原文 Note, two of your comments are wrong. SSP1CON1 = 0x28; // MSSP Enable as IIC Master at FOSC/4 SSP1CON2 = 0x00; SSP1ADD = 0x28; // Set I2C address, Set IIC Bus for 100 kHz should be: SSP1CON1 = 0x28; // MSSP Enable as IIC Master at FOSC/(4 * (SSPxADD+1)) SSP1CON2 = 0x00; SSP1ADD = 0x28; // Set IIC Bus for 100 kHz and also note, if your clock is 16MHz, then SSP1ADD should have been 39, which is 0x27, to get 100kHz. |
|
|
|
谢谢大家回复我的信息。谢谢QBH。问题被你的消息解决了。我真傻…不要将RB4配置为数字输入……只要我配置这个管脚作为输入,MSSP:IIC主机就开始工作。再次感谢您!!!!我必须使用ANSELB=0;指令将PUTB配置为数字输入引脚。对于其他芯片,相应地配置引脚。这将有助于许多陷入类似问题的人。我提到过许多具有相同问题的帖子,但是没有人能解决这个问题,您帮助我解决了它,谢谢。谢谢DarioG,我本来可以张贴整个代码,但是它太大了。我会发送整个帖子,但它包含许多与产品设计相关的内容,这会使正在寻找这个问题解决方案的其他人感到困惑。如果你仍然想要它,我会张贴它,没问题。但是谢谢你的答复。由于MSSP正在处理SDA和SCL引脚,我不必使用PORTx和LATx指令,但是谢谢你的答复。问题解决了!!!!感谢QBH,以纠正评论中的错误。
以上来自于百度翻译 以下为原文 Thanks to all of you for replying to me message. Thanks QBH. The problem was solved by your message. How silly of me ... NOT configuring the RB4 as Digital Input....as soon as I configured this pin as input, the MSSP:IIC Master started working. Thanks to you again !!! I had to use the ANSELB = 0; instruction to configure the PORTB as Digital Input Pin. For other chips, configure the pins accordingly. This will help many people who were stuck up similar problem. I have referred to many posts with the same problem, but nobody had a solution for this problem, you helped me to solve it, thank you. Thanks DarioG, I would have posted the whole code, but it was too huge. I would send the whole post, but it contains a lot many things related to the design of the product, which will confuse the others who are looking for a solution to this problem. If you still want it, I will post it, no problem. But thanks for your reply. Since MSSP is taking care of SDA and SCL pins, I don't have to use the PORTx and LATx instructions, but thanks for your replies. PROBLEM IS SOLVED !!! Thanks QBH, for correcting the mistakes in the comments. |
|
|
|
只有小组成员才能发言,加入小组>>
5162 浏览 9 评论
2000 浏览 8 评论
1928 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3172 浏览 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-23 05:50 , Processed in 1.252472 second(s), Total 82, Slave 65 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号