This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LC4357: i2cNotification or i2cInterrupt

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Dear Jagadish

I would like to know when the i2cNotification and the i2cInterrupt is triggered after the mcu start up. My software has performed i2cInit(). Is it before a calling of an i2c send or receive api (eg i2cReceive(i2cBASE_t *i2c, uint32 length, uint8 * data)) or after calling an i2c send/receive api. I have configured the i2c in interrupt mode by enabling the i2c interrupts.

Thank you.

  • Hi LayEng,

    Is it before a calling of an i2c send or receive api (eg i2cReceive(i2cBASE_t *i2c, uint32 length, uint8 * data)) or after calling an i2c send/receive api.

    The interrupts will be generated after calling the send and receive api only.

    Transmit interrupt Process:

    As you can see the TXRDY interrupt will be generated after data has been copied from data transmit register (I2CDXR) into the transmit-shift register (I2CXSR).

    So, after calling the i2cSend function the code execution will go to the below highlighted instructions:

    So, in this function you can see first we will write the first byte to be transmitted into the data transmit register (I2CDXR) after that we will just reduce the length and enable the TXRDY interrupt and will get exit from this function. So now what will happen is, as soon as this first byte we have written into the data transmit register (I2CDXR) get moved to the transmit-shift register (I2CXSR) then processor immediately will get the TXRDY interrupt and the execution will moved to the case-5 in the "i2cInterrupt" function.

    So as our first byte got moved to shift register right so the data transmit register (I2CDXR) is empty now, so now we can send another byte, that is why again we will verify length here and if length is not zero then we will access the next data in the source buffer and we will move that data to the I2CDXR. And this process will continue till all the required bytes are transmitted.

    Receiving Interrupt Process:

    The receive interrupt will get generated as soon as data in the receive-shift register (I2CSR) has been copied into the data receive register (I2CDRR).

    Similar to the transmission here also first we will call the "i2cReceive" with required number of data bytes to be received and destination buffer address. 

    As our RXINT already got enabled in the i2cInit function here we will just initialize the receive length and destination buffer address and we will exit from the function. So, after exit from this function whenever we received a byte from slave to the master the data first will get shifted into the receive-shift register (I2CSR) and after that the data will get moved to the data receive register (I2CDRR). So, as soon as i2c master receives a byte into the I2CDRR register the processor immediately will get the RXRDY interrupt and the execution will now move to the case-4 of the "i2cInterrupt" function.

    Now here we will first copy the received byte in the I2CDRR register to the first location of the destination buffer and after that we will reduce the length by one and increment the destination buffer address by one to store the next byte. And now we will verify whether length is zero or not, if length is not zero means still, we need to receive more data right so we will again enable the RXRDY interrupt, and we will exit from this loop. If master receives another byte again to the I2CDRR register then again, we will get this interrupt and process will get repeat until all the required bytes received to the destination buffer.

    This is how the process of transmitting and receiving will work in interrupt mode.

    --

    Thanks & regards,
    Jagadish.

  • Dear Jagadish

    I have a hardware whereby the stop bit interrupt came after i2cInit(). For that hardware, the entire i2c of the devices work normally, i.e. the mcu is able to send and receive from the slave device. For many hardware, as I mention earlier, we have 3 pcs,  the interrupts don't work at all. So it is presumed the hardware is faulty. However, I don't think the hardware is faulty but I don't understand why this behaviour happens. 

    Any advice?

  • Hi LayEng,

    Can we setup one live debugging session?  In this session can you able to show me by connecting both boards and what is the behavior difference you are seeing?

    I will be available from 10AM to 7PM IST (Indian Standard Time).

    This is required because, i never saw any similar issue in the past.

    --

    Thanks & regards,
    Jagadish.

  • Dear Jagadish

    Thank you for your offer. I am still debugging. I have gone back to using the sample code which you gave me some time in April this year. I have added using i2c1 and i2c2 interrupt via halcogen. Unfortunately, I can't get i2c2 interrupt. Can help to check why I can't get i2c2 interrupt in halcogen? 

    Attached is my code. Thank you

  • How to upload the zip file? Please advise. Thanks

  • I can't compile this file because of i2c2Interrupt not available. Please check the hcg file and tell me where I have made a mistake. Thank you. 

    I have corrected pinmux, vim channel and selected interrupts in i2c2 

  • Hi LayEng,

    I can't compile this file because of i2c2Interrupt not available. Please check the hcg file and tell me where I have made a mistake. Thank you. 

    I have corrected pinmux, vim channel and selected interrupts in i2c2 

    Apologies for the delay,

    I don't understand your concern here.

    If you can't find i2c2 interrupt in HALCoGen, then it is here at 114 channel.

    Once you enabled it and select the i2c2 driver then its definition will be generated in i2c.c file

    --

    Thanks & regards,
    Jagadish.

  • Hi

    I think there is a bug in halcogen. Attached is the .hcg file. I have also attached the image of the different files I have changed. Again no i2c2 interrupt. FYI, I have done this checking and code generation via halcogen a few times. I can see that vim channel 114 is enabled (that is why I have compiled error). I can see that the hcg file is not changed but the .dil file is changed. Shouldn't the hcg file be changed if I have changed the i2c configuration? I am attaching also the hcg and dil file. Looking forward to your support. Thank you

  • The generated HL_i2c.c don't have i2c2 codes. Hence the errors. 

  • Hi LayEng,

    You didn't attach the any compiler error images. How can i know what kind of compiler errors you are getting?

    And i also compiled your attached project "5164.I2C_TEST_LC43", there also i didn't see any compiler issues the code get build successfully only.

    Please reverify it.

    --

    Thanks & regards,
    Jagadish.

  • Dear Jagadish

    Very sorry for attaching the wrong zip file. I have attached the correct one. Please check.I2C_TEST_LC43 to TI.zip

  • Thanks for your support. I would also like to know why the hcg file don't seem to change (still dated 2022 despite changes) and that only dil file is changed. 

  • Hi LayEng,

    Apologies for the delay, i am on vacation for last week.

    Very sorry for attaching the wrong zip file. I have attached the correct one.

    Thanks for the code i will test it right now.

    I would also like to know why the hcg file don't seem to change (still dated 2022 despite changes) and that only dil file is changed. 

    If we just generate the code by making some changes then only .dil and driver files will get updated.

    To update HCG file then we should click on "Save Project" option.

    --

    Thanks & regards,
    Jagadish.

  • Hi LayEng,

    Very sorry for attaching the wrong zip file. I have attached the correct one. Please check.I2C_TEST_LC43 to TI.zip

    I just verified and found the compiler error route cause.

    The issue is due to, you are enabling the i2c2 interrupt in VIM but you are not enabling the i2c2 driver.

    Here you enabled the i2c2 interrupt from VIM:

    But here you are not enabling the i2c2 driver:

    If you don't enable the i2c2 driver then HALCoGen won't generate the definition for the "i2c2Interrupt" function right? That is the reason why you are getting compiler error.

    If you want to use "i2c2Interrupt" then please generate the corresponding driver also otherwise it is not a valid scenario because we can't use i2c interrupt without the driver file.

    This is the output of the build after i enabled the i2c2 driver:

    --

    Thanks & regards,
    Jagadish.