睡眠态中唤醒

[复制链接]
315|9
手机看帖
扫描二维码
随时随地手机跟帖
morrisk|  楼主 | 2019-8-4 13:46 | 显示全部楼层 |阅读模式

可以判断已经从睡眠态中唤醒了,但是直接EzI2Cs_Start();i2c不能通信,怎么办?

使用特权

评论回复
zyf部长| | 2019-8-4 13:49 | 显示全部楼层
找到一个资料

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

使用特权

评论回复
morrisk|  楼主 | 2019-8-4 13:51 | 显示全部楼层

嗯,这是我根据资料写的程序
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;        
}
可是还是不行

使用特权

评论回复
xxmmi| | 2019-8-4 14:23 | 显示全部楼层
延时不等于 4 I2C sample clock periods吧

使用特权

评论回复
morrisk|  楼主 | 2019-8-4 14:26 | 显示全部楼层
这个时间怎么算

使用特权

评论回复
kangzj| | 2019-8-4 14:29 | 显示全部楼层

我看到这个问题在AN50897 15页 不是这样说的
http://www.cypress.com/index.cfm?rID=34486

使用特权

评论回复
zwll| | 2019-8-4 14:32 | 显示全部楼层
i2c主机一直在读取从机的数据,所以唤醒时数据位跟地址位错乱,无法通信

使用特权

评论回复
chuxh| | 2019-8-4 14:35 | 显示全部楼层
资料的步骤跟AN50897手册的过程是一致的,都可以实现。

使用特权

评论回复
juventus9554| | 2019-8-4 14:39 | 显示全部楼层
lz用的是自带的I2C模块么?

使用特权

评论回复
morrisk|  楼主 | 2019-8-4 14:41 | 显示全部楼层


哦,那我就知道怎么回事了,多谢大家,结贴了哈

使用特权

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

本版积分规则

701

主题

6879

帖子

2

粉丝