我已经单独做了个初始化I2C口的工程 I2C_read16(hI2C,0,0x00);在这个函数就不运行了。程序见附件
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
我已经单独做了个初始化I2C口的工程 I2C_read16(hI2C,0,0x00);在这个函数就不运行了。程序见附件
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);
另外,I2C模块的初始化
7.1.1 State After Reset
1) Program the I2C prescaler register (I2CPSC) to obtain the desired prescaled
module 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 appropriate
interrupt in I2CIER.
b) If using the EDMA controller for transmit/receive data, enable the
EDMA and program the EDMA controller.
7.1.2 Initialization Procedure
Configure 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 obtain
the desired SCL clock timing (see section 8.4). These values are to be calculated
and are dependent on the CPU frequency.
7.1.4 Configure Address Registers
1) 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