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

SM470R1B1M I2C

有谁在使用SM470R1B1M这款芯片,上次调试SPI口时遇到的问题已经解决了,但是I2C一直调试不通,初始化不通过,代码如下:

void I2cInit(void)
{
I2C2MDR= 0; // Reset the I2C module

// I2C addresses
I2C2OAR = 0x00; // My Own Address

// Configure for 400 kHz bitrate with 60 MHz SYSCLKOUT
// I2C bus clock = I2C_module_clock/[(I2CCLKL + d) + (I2CCLKH + d)]
// where d=5 when I2CPSC = 5.
// Oscillator clock is 7.5Mhz

// Multiply with 8 , Divide by 1
// Sysclk = 7.5 * 8 = 60Mhz
GCR &= ~ZPLL_MULT4;
GCR &= ~ZPLL_CLK_DIV_PRE1;
GCR &= ~ZPLL_CLK_DIV_PRE2;
GCR &= ~ZPLL_CLK_DIV_PRE3;

// Divide by 6
// Peripheral clock (ICLK) = SYSCLK / 6 = 10.0MHz
PCR = CLKDIV_6;
PCR |= PENABLE; // enable peripherals
I2C2PSC = 5; // SYSCLKOUT/(IPSC+1) = 10 MHz module clock (must be 7-12 Mhz)
I2C2CKL = 10; // Allow more time when clock is low to allow SDA to change
I2C2CKH = 5; // Need less time when clock is hi

// General configuration
//I2caRegs.I2CFFTX.bit.I2CFFEN = 0; // FIFO mode disabled
I2C2IMR = 0x0000; // No interrupts enabled

//I2C2MDR = 0x2E20; // DLB=0
I2C2DIR|= SCLFUNC|SDAFUNC; //Set SDA and SCL as I2C Function pins
I2C2MDR = NIRS; // Take I2C out of reset
//REQMASK = (1 << CIM_I2C2);

void I2cTx(void)
{
I2C2SAR = 0xA0; // 10-bit Address of slave being transmitted to
I2C2CNT = 1; // Transmit count (1 = 1 word)
I2C2SR |= 0x1<<5; // Clear the SCD bit (stop condition bit)
I2C2MDR = 0x2E20; // DLB=0
// bit 15 0: NACKMOD, 0 = SEND acknowledge
// bit 14 0: FREE, 0 = halt on emulation suspend
// bit 13 1: STT, 1 = start transmission
// bit 12 0: reserved
// bit 11 1: STP, 1 = generate stop condition when I2CCNT = 0
// bit 10 1: MST, 1 = master mode
// bit 9 1: TRX, 1 = transmitter mode
// bit 8 0: XA, 1 = 10-bit addressing, 0 = 7-bit addressing
// bit 7 0: RM, 0 = nonrepeat mode
// bit 6 0: DLB, digital loopback, 0 = disabled, 1 = enabled
// bit 5 1: IRS, 1 = normal operation, 0 = reset
// bit 4 0: STB, 0 = START byte mode disabled
// bit 3 0: FDF, 0 = Free data format mode disabled
// bit 2-0 000: BC, 000 = 8 bits per data byte

在调试运行时,红色字体处是 0x0220,而不是 0x2e20,用示波器观察也无法观察到波形 ,我的SDA和SCL上都加了 上拉电阻(2.35K),不知道问题出在哪了

谁可以帮我一下 ,或者给我 一下I2C的 历程 

Susan Yang:

可以参考这个链接http://e2e.ti.com/support/applications/high_reliability/f/30/t/146168.aspx  

以及http://www.ti.com/tool/heatevm 下载HEATEVM Firmware

wen xiaozhe:

回复 Susan Yang:

请问你有这个SM470R1B1M的有关开发例程吗如SPI或者AD采集

Ken Wang:

这颗芯片已经不建议在使用了,而且国内没有相关这个芯片的支持。

例程很少的。

谢谢

赞(0)
未经允许不得转载:TI中文支持网 » SM470R1B1M I2C
分享到: 更多 (0)