CodeMonkey 发表于 2013-4-22 21:58:58

AVR Mega TWI 怎样配置低功耗

比如有这么一个函数.void SetLM75(unsigned char RegisterAddr,unsigned char HValue,unsigned char LValue){
      TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);//发送开始信号
      while (!(TWCR & (1<<TWINT)));
      TWDR = LM75_Address_W;//写信号
      TWCR = (1<<TWINT)|(1<<TWEN);
      while (!(TWCR & (1<<TWINT)));
      TWDR = RegisterAddr;//寄存器地址
      TWCR = (1<<TWINT)|(1<<TWEN);
      while (!(TWCR & (1<<TWINT)));
      TWDR = HValue;//寄存器地址
      TWCR = (1<<TWINT)|(1<<TWEN);
      while (!(TWCR & (1<<TWINT)));
      TWDR = LValue;//寄存器地址
      TWCR = (1<<TWINT)|(1<<TWEN);
      while (!(TWCR & (1<<TWINT)));
      TWCR = TWINT+TWSTO;//STOP信号
      while (!(TWCR & (1<<TWINT)));
}通过查询标志的方法,不能达到降低功耗的模式,那么,应该在TWCR时候置位TWIE(中断允许位),然后添加一个空中断.ISR(TWI_vect){
        //空中断       
}以便进入模式后唤醒吧,(先sei再sleep)问题是,他只有一个TWI Address Match的中断唤醒源,发送Start后根本不唤醒,还是我使用Timer 2设置一个定时唤醒呢?

求做过低功耗的说说.

ordinary 发表于 2013-8-12 21:10:13

可以使用中断方式驱动IIC
页: [1]
查看完整版本: AVR Mega TWI 怎样配置低功耗