Page 1 of 1

Need help with I2C register access in bootloader

Posted: Tue Sep 25, 2018 6:26 am
by rahul.b.patel
Hello,
I have a requirement to use I2C in bootloader in master mode. As I2C driver is not added as component into bootloader, using I2C with low level registers is the only way to do it.
I have tried to configure I2C registers from TRM as below, but not getting success.
Can anyone point me out what am I missing in it.?

Code: Select all

gpio_matrix_out(15, I2CEXT0_SDA_OUT_IDX, 0,  0);       //set output signal for io_matrix
gpio_matrix_in (15, I2CEXT0_SDA_IN_IDX, 0);            //set input  signal for io_matrix
gpio_matrix_out(2, I2CEXT0_SCL_OUT_IDX, 0,  0);       //set output signal for io_matrix
gpio_matrix_in (2, I2CEXT0_SCL_IN_IDX, 0);            //set input  signal for io_matrix

DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2C_EXT0_CLK_EN);	/*	enable clock	*/
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_I2C_EXT0_RST);

WRITE_PERI_REG(I2C_CTR_REG(0),0xff);
WRITE_PERI_REG(I2C_FIFO_CONF_REG(0),I2C_NONFIFO_EN);
WRITE_PERI_REG(I2C_SDA_HOLD_REG(0),10);
WRITE_PERI_REG(I2C_SCL_LOW_PERIOD_REG(0),14); 
WRITE_PERI_REG(I2C_SCL_HIGH_PERIOD_REG(0),14); 
WRITE_PERI_REG(I2C_SDA_SAMPLE_REG(0),10); 

/* command and data write */
WRITE_PERI_REG(I2C_COMD0_REG(0), 0x00);	/* start */
WRITE_PERI_REG(I2C_COMD1_REG(0), 0x803);	/* write	*/
WRITE_PERI_REG(I2C_DATA_APB_REG(0), 0x20 << 1 | 0);	/*	slave address with write	*/
WRITE_PERI_REG(I2C_DATA_APB_REG(0), 0x07);	/*	data  */
WRITE_PERI_REG(I2C_DATA_APB_REG(0), 0x00);	/* data	*/
WRITE_PERI_REG(I2C_COMD2_REG(0), 0x1800);		/* stop	*/
Can anyone help what am I missing in it.? Or if there is any other way to use i2c_driver.c directly in bootloader.

Thanks.

Re: Need help with I2C register access in bootloader

Posted: Wed Sep 26, 2018 3:53 am
by rahul.b.patel
Hello Guys,
Can any body help me with this.?

Thanks.

Re: Need help with I2C register access in bootloader

Posted: Mon Oct 01, 2018 3:46 am
by rahul.b.patel
Hello Guys,
Can you please look above configurations if I am missing anything.?

Thanks.

Re: Need help with I2C register access in bootloader

Posted: Mon Mar 25, 2019 7:31 pm
by Soloxxx666
Hi Raul,
I'm having the same problem. Did you manage to resolve this?

Best.

Re: Need help with I2C register access in bootloader

Posted: Tue Mar 26, 2019 4:01 am
by rahul.b.patel
Soloxxx666 wrote:
Mon Mar 25, 2019 7:31 pm
Hi Raul,
I'm having the same problem. Did you manage to resolve this?

Best.
Hello,
No I dropped this and skipped to make any changes in bootloader it self, so did not check anything further in this.