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
...
}
Did you check the I2C sample code from the Renesas homepage?
http://documentation.renesas.com/eng/products/mpumcu/apn/rej05b0145_m16cap.pdf
Yes I did that ...
I think the documentation is a bit messy, regards how to use/configure the i2c master mode!
Any sample of reliable code???
Thanks very much,
David.
The source code for a working project is also on the website:
©2003–2009 Renesas Technology Corp. All rights reserved. Using Our Website | Privacy
Contact us