Question about handling IIC00 clock stretching on RL78G14

Hello,

I have a question about handling clock stretching for IIC00 on RL78/G14.

Basic information:
After initialization, the application will just read every sensor through IIC00 every 5ms.
The IIC00 baud rate is set to 400k and all the sensor are on the same bus.
Thoes sensors include a GPS, some thermometer, some accelerometer, etc.

I have confirmed that all sensors works properly if we do not communicate with the GPS module.
However, if I try to read the GPS, a clock stretch may happened and the SCL is being pulled LOW which caused the next IIC00 clock goes wrong.



Attach is the wave captured from the oscilloscope.
SDA is in yellow and SCL is in green color.
As shown in left part, the tail part of clock for (A)GPS is "disappeared".
As well as the next IIC00 communication, the tail part of clock for (B) is also missing.
I believe the r_iic00_callback_master_error interrupt is called on (B) after the first clock sent.
However, actually the clock is already "broken" on half way of (A)

 

According to the manual, the following handling is done when MD_STATUS == 2 (IIC no ACK).
SIR00 = SSR00;
ST0 = 0x80;

R_IIC00_StopCondition();
R_IIC00_Stop();
R_IIC00_StartCondition();
SS0 = 0x1;

I found on Hardware manual that we can change the transfer clock frequency by setting the SDR00.
I have tried to adjust the rate in between the but seems do not work.

I would like to ask:
1. How to deal with clock stretching?
How long should I wait or I could do something else to reset it?
2. Is there any problem if I change the SDR00 inbetween the transmission of IIC00?

Best Regards,
Joe

  • I have two more question about IIC.

    To simply the IIC testing, I just include a GPS and a Accelerometer. They are called sequentially like this:
    [GPS: R_IIC00_Master_Receive 2 bytes to read the current register address (Slave address & 1 byte clock time)]
    -> StopCondition
    -> [Accelerometer: R_IIC00_Master_Send 2 bytes (Slave address & Register address)]
    -> [Accelerometer: R_IIC00_Master_Receive 7 bytes (Slave address & 6 bytes clock time)]
    -> Stop Condition
    -> (loop until the next 5ms time ticked, and read both sensor again)

    So my question is:
    1. If there is a slave always NACK (GPS), and I would like to handle only when it returns ACK, what is the best way to handle this case?
    2. Continue with question 1, R_IIC00_Master_Receive needs to provide slave address with appropriate clock time. Is there any way I can split these? i.e. Is there any way I can only send the slave address first, and then try to read in some time later?
  • In reply to JoeL:

    Hi JoeL,

    How's this issue? Any progress on this?

    JB
    RenesasRulz Forum Moderator

    https://renesasrulz.com/
    https://academy.renesas.com/
    https://en-us.knowledgebase.renesas.com/