Closed Juninho99 closed 5 months ago
Changes in the branch issue#1 have resolved the first part of the problem, i.e. the I2C section no longer starts before the srst
signal. This was achieved by inverting the logic of the i2c_reset
. Simulation results confirm that this part is now resolved.
However, there remains an issue highlighted in the image: the first sent slave address is 0. This is further illustrated in the second image, where it is evident that the second register has the correct slave_address
.
The issue of the first slave address being 0 has been resolved by setting slave_address
as the parameter I2C_SLAVE_ADDR
in the top/u_i2c module
, ensuring it is defined from the start. The solution is evident from the image below.
Fix I2C reset issue
First Issue:
The
i2c_reset
signal, which is generated in thetop/u_clkrst_gen
module, is based on thesrst
signal from thetop/u_clkrst_gen/u_pll_top
module. Since thesrst
signal does not occur at the very beginning, thei2c_reset
signal is also delayed, as shown in the attached image. The image illustrates that as a consequence,i2c_sda
andi2c_scl
start, but then halt due to the reset.The solution would be to ensure that
i2c_reset
is initially set to 0 and remains 0 until therst_delay_cnt
counter reaches 4 (since the I2C is enabled only after 4 seconds from the system power-up).Second Issue:
When the
reset
signal in thetop/u_i2c
module goes to 0, data transmission on the I2C bus begins. However, at that moment, the value of the slave address, which is the first data transmitted via I2C, is set to an undefined value. Consequently, the setting of theslave_address_plus_rw
(slave address plus read/write) signal is delayed by one data transmission cycle via I2C, which is not desirable. As a result, the first slave address written is 0.To solve this second problem, the slave address should be set before the start of the I2C section. One approach is to introduce an additional input signal (which can be
cam_en
, as it occurs before thei2c_reset
, as shown in the image).