打印

从睡眠中唤醒 之后i2c要如何恢复

[复制链接]
5943|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
xiariguodong|  楼主 | 2012-7-17 09:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
rt,可以判断已经从睡眠态中唤醒了,但是直接EzI2Cs_Start();i2c不能通信,怎么办???等高手!!!
沙发
xiariguodong|  楼主 | 2012-7-17 09:43 | 只看该作者
自己顶一下,来个人呐

使用特权

评论回复
板凳
xiariguodong|  楼主 | 2012-7-17 09:52 | 只看该作者
找到一个资料

PSoC1 I2C: Usage description with sleep

Last Updated: 02/24/2010
For all PSoC1 devices (CY8C20xxx, CY8C21xxx, CY8C22xxx, CY8C24xxx, CY8C27xxx, CY8C29xxx) it is highly recommended to restart the I2C block following the below procedure after coming out from sleep. This is to avoid ongoing I2C traffic in the bus to disrupt PSoC I2C block state machines.

Procedure to restart I2C block,

Step1: Disable I2C block (by clearing the ‘Enable’ bit in the I2C_CFG register)

Step1: Put I2C SDA & I2C SCL pins to ‘HI-Z Analog’ drive mode

Step2: Enable I2C block (set the ‘Enable’ bit in the I2C_CFG register)

Step3: Give delay equal to 4 I2C sample clock periods

Step4: Restore I2C SDA & I2C SCL pin drive modes back to OD-LOW

这是我根据资料写的程序
void i2c_restart(void)
{
        BYTE i,j;
        I2C_CFG &=~0x01;//disable i2c;
        PRT1DM0        &=~0x03;
        PRT1DM1        |=0x03;
        PRT1DM2        &=~0x03;
        I2C_CFG |=0x01;
        for(i=0;i<100;i++)
                for(j=0;j<120;j++);
               
        PRT1DM0        |=0x03;       
        PRT1DM1        |=0x03;
        PRT1DM2        |=0x03;       
}
可是还是不行,是因为延时不等于 4 I2C sample clock periods吗?如果是这个时间怎么算
来个人吧!!

使用特权

评论回复
地板
jxin| | 2012-7-17 12:00 | 只看该作者
我看到这个问题在AN50897 15页 不是这样说的
http://www.cypress.com/index.cfm?rID=34486

使用特权

评论回复
5
xiariguodong|  楼主 | 2012-7-17 15:18 | 只看该作者
感谢jxin,哈哈,解决了,是因为我的i2c主机一直在读取从机的数据,所以唤醒时数据位跟地址位错乱,无法通信,个人认为资料的步骤跟AN50897手册的过程是一致的,都可以实现。
再次感谢jxin!!

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

23

帖子

0

粉丝