Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
mari_3376811
Level 1
Level 1
10 sign-ins 5 sign-ins First reply posted

Can someone help.

I have configured the I2C (SCB) on my CYBLE-416045-02 using a combination of device configurator and the example code in MTB CAT1 Peripheral Driver Library (PDL). This works and I see data being exchanged with my device (accelerometer). My board is configured as a Master. I am using Master High-Level commands doing a send waiting then doing a read and wait again.

I see in the documentation that for Master High-Level functions interrupt is mandatory for I2C operation. It then says I have to call Cy_SCB_I2C_MasterInterrupt in the interrupt handler which I do.

I have test code in my interrupt handler that prints a message. It seems to get called twice for every read or write operation.

Firstly what does the call to Cy_SCB_I2C_MasterInterrupt in my interrupt routine do?

How do I distinguish what the interrupt event actually is? I see a function Cy_SCB_I2C_RegisterEventCallback but not sure if this helps.

Regards 

0 Likes
1 Solution
Aashita_R
Moderator
Moderator
Moderator
50 likes received 100 solutions authored 250 replies posted

Hi @mari_3376811 ,

The Cy_SCB_I2C_MasterInterrupt  should be called inside the user-defined interrupt service routine to make Master-High level functions to work. This is important because with the master high-level functions, the I2C transactions are performed and when these transactions are complete, Cy_SCB_I2C_Interrupts function manages the further data transfer. In case you want to read about the APIs in detail,  Please refer the PDL APIs page.

Also, in order to distinguish which interrupt even actually occurred you can make use of Cy_SCB_I2C_MasterGetStatus() function. It returns the current I2C master status. OR you can use the Cy_SCB_I2C_RegisterEventCallback() function which registers a callback function that notifies that I2C Callback events occurred in the Cy_SCB_I2C_Interrupt.

In case you want to refer the flow of code which should be followed using the above APIs, we would suggest you to kindly go through the PSoC Creator's "CE220818_I2C_Master_High_Level" code example for better understanding.

Please let us know if this helps or in case of any further query.

Best Regards,

Aashita

 

View solution in original post

1 Reply
Aashita_R
Moderator
Moderator
Moderator
50 likes received 100 solutions authored 250 replies posted

Hi @mari_3376811 ,

The Cy_SCB_I2C_MasterInterrupt  should be called inside the user-defined interrupt service routine to make Master-High level functions to work. This is important because with the master high-level functions, the I2C transactions are performed and when these transactions are complete, Cy_SCB_I2C_Interrupts function manages the further data transfer. In case you want to read about the APIs in detail,  Please refer the PDL APIs page.

Also, in order to distinguish which interrupt even actually occurred you can make use of Cy_SCB_I2C_MasterGetStatus() function. It returns the current I2C master status. OR you can use the Cy_SCB_I2C_RegisterEventCallback() function which registers a callback function that notifies that I2C Callback events occurred in the Cy_SCB_I2C_Interrupt.

In case you want to refer the flow of code which should be followed using the above APIs, we would suggest you to kindly go through the PSoC Creator's "CE220818_I2C_Master_High_Level" code example for better understanding.

Please let us know if this helps or in case of any further query.

Best Regards,

Aashita