AVR I2C故障 [英] AVR I2C trouble

查看:110
本文介绍了AVR I2C故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用I2C与AT90CAN128进行通信,但是它并没有超出while循环的要求:

I am trying to communicate using I2C with AT90CAN128, But it is not going further than following while loop:

while(!(TWCR & (1<<TWINT)));

它保留在while循环中. 据我说,它不能设置TWINT标志.

It remains in the while loop. According to me, it is not able to set TWINT flag.

void TWI_start(void)
{
  TWCR= (1<<TWINT)|(1<<TWSTA)|(1<<TWEN); 
  while(!(TWCR & (1<<TWINT)));`enter code here`
  while((TWSR & 0xF8)!= 0x08); 
}

有什么建议吗?

推荐答案

可能是硬件问题.

TWI主站试图声明SDA和SCL,并检查SDA和SCL是否都在GND.检查连接和上拉电阻的值.如果控制器无法将线拉低,则START条件永远不会被注册,并且TWINT也永远不会被设置.

The TWI Master tries to assert SDA and SCL and checks if both SDA and SCL are at GND. Check the connections and the value of your pull-up resistors. If the controller fails to pull the lines down, the START condition never gets registered and TWINT will never get set.

这篇关于AVR I2C故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆