I2C FSP (RA4M1)

In the FSP for the I2C driver, where do I find explanations of the parameters?
e.g. I2C channel: is that simply the channel number? 0 or 1?

I2C MASTER RATE FAST has a link, which tells me it is the 400kHz clock. Does it calculate the delays itself from the clock speed?
I2C SLAVE EEPROM. What is that? Does it mean the slave address? It can vary depending on how pins 1, 2 and 3 are set on the device being addressed.

p.context. That seems to be the address of itself? Doesn’t it know its own address?

p.transfer-tx, p.transfer-RXD, p.extend. No explanations are offered.

what do I put for p.callback if I don’t want to use a callback function?

Do I need to run IIC-Close after every transaction? If so, does it power down the peripheral or not? It says it “may” do. Does it use the random number generator to decide whether it does or it doesnt?

Thankfully there are a few parameters that are clear: the address and size of the buffer!

  • I2C channel: Yes, it can only be 0 or 1. Depends where pins are you using.

    In the rate selection, the driver do the calculations to achieve this speed.

    I2C SLAVE EEPROM: If you only have a slave device, put here his address and you will not need do more about adressing. If you have more than one slave device, you can't ignore it and just use the function R_IIC_MASTER_SlaveAddressSet before read or write.

    p.context: I never use it, i can not tell you the benefit of it. This works like an item passed as a parameter in the callback. 

    p.transfer-tx, p.transfer-RXD, p.extend....: I don't know where are you looking to find this. This is not in the FSP, I think.

    If you want to use I2C without callback, put NULL in this box.

    Do I need to run IIC-Close after every transaction?: No, but if you are sure that I2C is no longer use, you can "turn off" this to reduce consumption.

    Greetings,

  • Thanks.

    Is the slave address 7-bits or 8? The data sheets often show it as 0xA0 to write and 0xA1 to read by including the R/W bit, whereas a 7-bit address is actually 0x50.

    And this is where I found p.transfer etc.

  • Hello,

    address is 0x50. When you call read or write, the driver send this address of 7 bits and then the bit R/W, so will be finally a 0xA0 or 0xA1.

    The variables you post is for the driver itself. When you make your settings in the FSP, you are writing these values.

    HAve you the I2C stack? Then, you don't need to see this variables, just only this beacuse is the same:

    Greetings,

  • Hello Ian,

    In general, David explains most of your questions. I want to add some more comments.

    First of all, your questions are about FSP architecture, so all the answers can be found on FSP documentation below:

    https://www.renesas.com/us/en/document/mas/renesas-flexible-software-package-fsp-v510-users-manual?r=658306

    1) p.context is used for providing user-specified data to the callback function. There are cases, that you can use a callback for different modules or channels of the same peripheral, and you want to determine for which module/channel the callback is for. So, inside the callback function, you can pass the control structure in the p_context. Usually, it is avoided to be used.

    2)p.transfer-tx,rx are transfer instances for I2C transmit or receive. Instance is a very significant structure on FSP arcihtecture, take a look on the attached screenshot that describes what it is:

    3) Ιt isn't mandatory to use callback functions as David mentioned.

    4) IIC_close disables all the interrupts, related to IIC peripheral and as David mentioned, you can use it if you don't want to use I2C module anymore on your application.

  • That configuration page is hard to find. Is there an easier link than Window->Show View->Properties ?
    i thought that the “info” link on the stack led to the relevant page of the FSP manual, but it only shows some of the manual. (That manual could use a copy editor - a few well-placed page breaks would make a huge difference!) However, it doesn’t tell me the difference between short and long timeout mode!
    I also see that the block of code it generates appears in hal-data.c, and it is the same block as included in the “example code”

  • The info link is a very good and fast way to have direct access to a specific stack (for example I2C).

    Your initial questions were more general on how FSP drivers work, that's why I sent the aforementioned link.

    Yes, every user's step during FSP configuration is stored on hal_data.c, that is an auto-generated fie, after clicking Generate project content.

    Please, could you define what you mean short and long timeout mode?

    Best Regards

  • In David’s screenshot (above) panel on the right, 14th line.



  • Well, I2C peripheral includes timeout function that uses an  internal counter, and inform the system when a specific time interval has passed without SCL line change state.

    If SCL changes state, the timeout function resets the counter, in differenr case a counter overflow is happens.

    Short mode means that the counter will be a 14-counter, while long mode means that the counter will be 16-bit. The count source of the counter is the internal reference clock that is configured through CKS[2:0] bits on ICMR1 register.

    Regarding the screenshots above, if you know the PCLKB clock frequency (please ignore 50Mhz, because the screenshot is from diffenrent mcu) and also you know the CKS configuration ( you can see the value for CKS bits on the hal.data.c file), you can calculate the time interval of a counter cycle.

    The next step is to decide if you prefer to have short or long mode. On short mode, the counter will measure up to 2^14*time interval  = 16384*time interval until an overflow happens, while on long mode the counter will measure up to 2^16*time_interval  = 65536*time intrval until an overflow happens.

    It's your decision, what you will select.

    Regards,

    AL_Renesas

  • Hello Ian,

    If you don't have anything else to ask about this request, can you please verify my answer for other members of  Community?

    Thanks,

    AL_Renesas