1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,
我正在为SPC560B54L5 micro开发一个I2C驱动程序,我在生成停止位时遇到了问题。 在写操作结束时,我运行以下伪代码: while(0 == IBSR.IBIF){/ * wait * /} IBCR.MSSL = 0 / *生成停止位* / while(1 == IBSR.IBB){/ * wait * /} 在几次成功传输(包括停止条件并返回空闲状态)之后,驱动程序在等待IBB位返回0时卡住。 我监控了SDA和SCL信号:有时没有生成停止条件,有时会生成停止但IBB不会丢失。 I2C以主模式运行,禁止中断。 此外,当我在逐步调试中运行驱动程序时,问题会在发送几帧后出现(包括停止条件并返回空闲状态)。 当我在不停止CPU的情况下运行驱动程序时,问题出现在第一帧上。 你能帮我找一下为什么没有生成或没有检测到停止条件? 最好的祝福, FAB #SP56-I2C 以上来自于谷歌翻译 以下为原文 Hi, I'm developing an I2C driver for a SPC560B54L5 micro, and I have problems generating the stop bit. At the end of a write operation, I run the following pseudo code: while (0 == IBSR. IBIF) { /* wait */ } IBCR.MSSL = 0 /* generate stop bit */ while (1 == IBSR.IBB) { /* wait */ } After a few successful transfers (including the stop condition and return to idle), the driver gets stuck while waiting for the IBB bit to return to 0. I monitored the SDA and SCL signals: some times the Stop condition is not generated, and some other times the Stop is generated but IBB does not drop. The I2C is run in Master mode, and interrupts are disabled. Also, when I run the driver in step-by-step debug, the problem appears after a few frames are sent (including Stop condition and return to idle). The problem appears on the first frame when I run the driver without stopping the CPU. Could you please help me find why the stop condition is not generated or not detected? Best regards, Fab #sp56-i2c |
|
相关推荐
6个回答
|
|
法比恩你好,
也许主人已经失去了仲裁。 (参见Rerefence Manual) 关于MSSL: 主/从模式选择。复位后,该位清零。当该位从0变为1时,a 在总线上生成START信号,并选择主模式。当这个位改变时 在1到0时,产生STOP信号,操作模式从主设备变为从设备。一个停止 只有在设置了IBIF标志时才应生成信号。 1主模式 0从机模式 最好的祝福 二万 以上来自于谷歌翻译 以下为原文 Hello Fabien , Maybe the master has lost arbitration. (cf Rerefence Manual) About MSSL : Master/Slave mode select. Upon reset, this bit is cleared. When this bit is changed from 0 to 1, a START signal is generated on the bus and the master mode is selected. When this bit is changed from 1 to 0, a STOP signal is generated and the operation mode changes from master to slave. A STOP signal should be generated only if the IBIF flag is set. 1 Master Mode 0 Slave Mode Best Regards Erwan |
|
|
|
你好,Erwan,
感谢您的回复。不幸的是,它看起来不像是仲裁丢失,因为当软件等待IBB下降时,IBSR.IBAL没有设置。此外,我正在测试的链接上只有一个(其他)设备,它只作为从属运行。 我调试了一些,只有在使用DMA写入数据时才会出现此问题。停止条件在SDA / SCL上生成,但IBB不会下降。 你知道解锁这种情况的方法,例如生成重启然后停止? 是否有针对I2C和DMA的应用笔记?有关此接口的参考手册有点模糊,我不确定在DMA传输结束时(发送或接收)需要在I2C控制器上执行什么操作。 最好的祝福, FAB 以上来自于谷歌翻译 以下为原文 Hello Erwan, Thanks for your reply. Unfortunately, it does not look like an arbitration loss, since IBSR.IBAL is not set when the software is stuck waiting for IBB to drop. Also, there is only one (other) device on the link I'm testing, and it only runs as a slave. I debugged some more, and this problem only appears when using DMA to write the data. The Stop condition is generated on SDA/SCL, but IBB does not drop. Would you know some way to unlock this situation, e.g. generating a restart then a stop ? Is there any application note for I2C and DMA ? The reference manual is a bit vague concerning this interface, and I'm not sure what needs to be done on the I2C controller at the end of a DMA transfer (either for sending or receiving). Best regards, Fab |
|
|
|
等待TCF解决了问题:
while(0 == IBSR.IBIF){/ * wait * /} while(0 == IBSR.TCF){/ *等待* /} IBCR.MSSL = 0 / *生成停止位* / while(1 == IBSR.IBB){/ * wait * /} 以上来自于谷歌翻译 以下为原文 Problem was solved by waiting for TCF: while (0 == IBSR.IBIF) { /* wait */ } while (0 == IBSR.TCF) { /* wait */ } IBCR.MSSL = 0 /* generate stop bit */ while (1 == IBSR.IBB) { /* wait */ } |
|
|
|
|
|
|
|
如果我要实现由中断例程驱动的传输,您是否碰巧知道是否有必要检查TCF?提前致谢。
以上来自于谷歌翻译 以下为原文 Would you happen to know if the checking of TCF is necessary if I were to implement the transfer driven by interrupt routines? Thanks in advance. |
|
|
|
你好Birdy,
通过软件例程,您必须检查。 如果你处于中断模式。我认为你没有检查TCF位 1 IBIE I-Bus中断使能。 0禁用I2C总线模块的中断。目前尚不清楚这一点 挂起中断条件。 1使能I2C总线模块的中断。发生I2C总线中断 如果状态寄存器中的IBIF位也置位。因为当出现下列情况之一时,IBIF位置1: - 仲裁丢失(IBAL位设置) - 字节传输完成(TCF位置1,DMAEN位未置1) - 作为从属地址(IAAS位设置) - 来自Slave的NoAck(MS& Tx位设置) - I2C总线空闲(IBB高低转换并由BIIE启用)最好的问候 二万 以上来自于谷歌翻译 以下为原文 Hello Birdy , By Software routine , you have to check. if you are in Interrupt Mode. I think that you have not to check TCF bit 1 IBIE I-Bus Interrupt Enable. 0 Interrupts from the I2C Bus module are disabled. This does not clear any currently pending interrupt condition. 1 Interrupts from the I2C Bus module are enabled. An I2C Bus interrupt occurs provided the IBIF bit in the status register is also set.because The IBIF bit is set when one of the following conditions occurs: – Arbitration lost (IBAL bit set) – Byte transfer complete (TCF bit set and DMAEN bit not set) – Addressed as slave (IAAS bit set) – NoAck from Slave (MS & Tx bits set) – I2C Bus going idle (IBB high-low transition and enabled by BIIE) Best regards Erwan |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2730 浏览 1 评论
3239 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1808 浏览 1 评论
3647 浏览 6 评论
6035 浏览 21 评论
1339浏览 4评论
198浏览 3评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
350浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
442浏览 2评论
STM32处理增量式编码器Z信号如何判断中断是正转的还是反向转的?
273浏览 2评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 06:00 , Processed in 1.242627 second(s), Total 88, Slave 72 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号