TI中文支持网
TI专业的中文技术问题搜集分享网站

求助6713 的I2C口初始化问题

我已经单独做了个初始化I2C口的工程 I2C_read16(hI2C,0,0×00);在这个函数就不运行了。程序见附件

noaming:

这个你可以先用示波器测量一下SCL,SDA引脚的信号,看看是什么情况

user4465613:

回复 noaming:

SCL,SDA引脚的信号一直是高电平

时钟用的是内部时钟 配置如下

 PLL_bypass(); PLLDelay(20); /* Reset PLL */ PLL_reset(); PLLDelay(20); /* Set main multiplier/divisor */  PLL_RSET(PLLM, 18);                         // 25MHz  x 18 = 450MHz  PLL_RSET(PLLDIV0, PLL_PLLDIV0_RMK(1, 0));  // 450MHz / 1 = 450MHz  PLL_RSET(OSCDIV1, PLL_OSCDIV1_RMK(1, 4));  // 25MHz  / 5 = 5Mhz  /* Set DSP clock */  PLL_RSET(PLLDIV1, PLL_PLLDIV1_RMK(1, 1));  // 450MHz / 2 = 225MHz  PLLDelay(20);  /* Set peripheral clock */  PLL_RSET(PLLDIV2, PLL_PLLDIV2_RMK(1, 2));  // 450MHz / 3 = 150MHz  PLLDelay(20);  /* Set EMIF clock */  PLL_RSET(PLLDIV3, PLL_PLLDIV3_RMK(1, 4));  // 450MHz / 5 = 90MHz  PLLDelay(20);  /* Take PLL out of reset */  PLL_deassert();  PLLDelay(1500);  /* Enalbe PLL */  PLL_enable();  PLLDelay(20);

user4465613:

回复 noaming:

程序我就是参照这个网址的例子编的

http://www.docin.com/p-1243415759.html?qq-pf-to=pcqq.c2c

noaming:

回复 user4465613:

你好,对应于你的程序,单步调试一下,看看I2CPSCx,I2CCLKHx,等等这些I2C寄存器里的值,都赋值正确了吗

noaming:

回复 user4465613:

另外,I2C模块的初始化

7.1.1 State After Reset1) Program the I2C prescaler register (I2CPSC) to obtain the desired prescaledmodule clock for the operation of the I2C module (see section 8.11).This value is to be calculated and is dependent on the CPU frequency.2) Take the I2C module out of reset (IRS = 1).a) If using interrupt for transmit/receive data, enable the appropriateinterrupt in I2CIER.b) If using the EDMA controller for transmit/receive data, enable theEDMA and program the EDMA controller.7.1.2 Initialization ProcedureConfigure the I2C mode register (I2CMDR) (see section 8.9).7.1.3 Program Clock Control Registers (I2CCLKL and I2CCLKH)Program the I2C prescaled module clock (I2CCLKL and I2CCLKH) to obtainthe desired SCL clock timing (see section 8.4). These values are to be calculatedand are dependent on the CPU frequency.7.1.4 Configure Address Registers1) Configure its own address register (I2COAR) (see section 8.1)2) Configure the slave address register (I2CSAR) (see section 8.7)

等等,这些I2C初始化步骤,可以在下面资料30页中查看

http://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=spru175&fileType=pdf

user4465613:

回复 noaming:

我下载了这个6116.i2c_6713_example.zip例程 这个是配置的I2C1口吧,我现在硬件上用的是I2C0口,需要改变哪些设置吗?

user4465613:

回复 noaming:

您好!

void main(void){                  int i=3;        /* set core to 200MHz */        setPLLto200MHz();                /*Enable I2C1 */        DEVCFG_ENABLE_I2C1();                /*Opening I2C Handle */           hI2CA=I2C_open(I2C_DEV0, I2C_OPEN_RESET);

这个是打开的I2C0口,但是上一个语句是/*Enable I2C1 */使能的I2C1口。这有什么影响吗?

赞(0)
未经允许不得转载:TI中文支持网 » 求助6713 的I2C口初始化问题
分享到: 更多 (0)