Skip to main content
Visitor II
June 29, 2006
Question

basic i2c

  • June 29, 2006
  • 3 replies
  • 770 views
Posted on June 29, 2006 at 14:05

basic i2c

    This topic has been closed for replies.

    3 replies

    ahmadAuthor
    Visitor II
    June 29, 2006
    Posted on June 29, 2006 at 09:29

    hi,

    i'm a student currently working with STR712FR2. I'm trying to use I2C and have basically wrote a simple code to check the signal out from it. it compiles well and didnt gave any error but the problem is i couldnt detect any signal using oscilloscope. anybody can help me with this?

    heres my code

    #include ''71x_lib.h''

    #include ''i2c.h''

    int main (void)

    {

    u32 MCLK_Freq;

    #ifdef DEBUG

    debug();

    #endif

    /* Configure the SDA and the SCL lines to alternate functions Open Drain (MASTERS) */

    GPIO_Config(GPIO1,0x2000,GPIO_AF_OD);

    GPIO_Config(GPIO1,0x4000,GPIO_AF_OD);

    /* Initialize the I2C0 peripheral */

    I2C_Init (I2C0);

    /* Configure frequency bits */

    I2C_FCLKConfig (I2C0);

    /* Enable I2C0 peripheral */

    I2C_OnOffConfig (I2C0, ENABLE);

    /*compute internal RCCU value*/

    MCLK_Freq = RCCU_FrequencyValue(RCCU_MCLK);

    /* Configure I2C0 clock speed */

    I2C_SpeedConfig (I2C0, 100000);

    /* Enable Acknowledge */

    I2C_AcknowledgeConfig (I2C0, ENABLE);

    /* Generate the START condition */

    I2C_STARTGenerate (I2C0, ENABLE);

    /* Wait until SB bit is set */

    while (I2C_FlagStatus (I2C0, DIRECT, I2C_SB)==RESET);

    while(1){

    I2C_ByteSend (I2C0,0X03);

    }

    thanx

    ahmadAuthor
    Visitor II
    June 29, 2006
    Posted on June 29, 2006 at 11:40

    hi,

    i'm using raisonance Reva starter kit.

    maybe this sound a bit stupid. whats a PU? is it a jumper that you put with the SCL & SDA pin. if then so, ive done that.

    thanks

    ahmadAuthor
    Visitor II
    June 29, 2006
    Posted on June 29, 2006 at 14:05

    hi again,

    well, ihave PU on the SDA and SCL and still it didnt give me any I2C signal. well the code looks correct to me. am i missing something ?

    thanks