This Question is Possibly Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
2,621 Views 3 Replies Last post: Jun 16, 2009 10:53 AM by ckgrier RSS
daparisi Newbie 5 posts since
Apr 27, 2009
Currently Being Moderated

Apr 27, 2009 11:03 AM

I2C Start condition generated - then lines are pulled up !

Hi there,

I have a problem with a m32c micro ... Im implementing an i2c master,

and when I generate the start condition, as soon as I write stspsel back to 0 (otherwise, I cannot write to the bus)

the lines SDA and SCL are pulled up for a while until I write to the u2tbl register ... this causes my part to think

that a clock/data was coming, which is wrong ...

 

Here is the code. Any help? What am I doing wrong? Thanks.

void i2c_start(void)
{
    unsigned int dly_tmr;
    dly_tmr = ta2;
    stspsel_u2smr4    = 0;
    while((dly_tmr - ta2) < _1ms ); // delay
    stareq_u2smr4 = 1;            // Start condition generate bit
    dly_tmr = ta2; while((dly_tmr - ta2) < _1ms ); // delay
    stspsel_u2smr4    = 1;        // SCL, SDA output select bit - set
    dly_tmr = ta2; while((dly_tmr - ta2) < _1ms ); // delay
    stspsel_u2smr4    = 0;        // SCL, SDA output select bit - reset   
}

 

main{

...

    te_u2c1 = 1;                // transmit data (enable bit)
    while(!ti_u2c1);            // wait for tx buffer to be empty
    ir_s2ric = 0;                // reset reception interrupt bit
    ir_s2tic = 0;                // reset transmission interrupt bit

 

    i2c_start();   
    u2tbl = Dev;                // transmit data

...

}

Tags: i2c, start, condition
FrankL Apprentice 1,100 posts since
Mar 16, 2009
Currently Being Moderated
Apr 28, 2009 4:37 AM in response to: daparisi
Re: I2C Start condition generated - then lines are pulled up !

Did you check the I2C sample code from the Renesas homepage?

 

http://documentation.renesas.com/eng/products/mpumcu/apn/rej05b0145_m16cap.pdf

ckgrier Apprentice 840 posts since
Mar 16, 2009
Currently Being Moderated
Jun 16, 2009 10:53 AM in response to: daparisi
Re: I2C Start condition generated - then lines are pulled up !

The source code for a working project is also on the website:

http://www.renesas.com/sensitivity.do?downloadId=D1014009

More Like This

  • Retrieving data ...

Bookmarked By (0)