I2C Slave Receive Interrupt...

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

cross mob
Tim_Shih
Level 5
Level 5
250 sign-ins 50 replies posted 50 questions asked

Dear Receiver,

I am testing PSoC4 I2C Master and Slave sample code.

I understand Master_Read, Master_Write, Slave_Write and Slave_Read from sample codes which are provided by PSoC creator 4.4.

But above sample codes are all for polling type.

I can't find sample code for slave receive interrupt.

Could you please help me to get a I2C slave interrupt (master - > salve, and slave interrupt immediately not polling ) sample code ?! 

Thank you so much.

0 Likes
1 Solution
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

Hi @Tim_Shih ,

Thank you for posting your query in the Community.
In PSoC Creator 4.4, we have the code example I2C_SCB_Slave_Callback code example which uses an interrupt based mechanism to set a flag which is polled by the firmware to check for command reception.

AlenAn14_0-1638628461902.png


If the above code example is not up to your requirements, you can also take a look at the thread  PSoC 4 I2C Slave Interrupts.

Do get back to me if the above examples does not meet your requirement.
Hope this helps.

Regards
Alen  

View solution in original post

7 Replies
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

Hi @Tim_Shih ,

Thank you for posting your query in the Community.
In PSoC Creator 4.4, we have the code example I2C_SCB_Slave_Callback code example which uses an interrupt based mechanism to set a flag which is polled by the firmware to check for command reception.

AlenAn14_0-1638628461902.png


If the above code example is not up to your requirements, you can also take a look at the thread  PSoC 4 I2C Slave Interrupts.

Do get back to me if the above examples does not meet your requirement.
Hope this helps.

Regards
Alen  

lock attach
Attachments are accessible only for community members.

Dear Alen,

As I know, in the PSoC interrupt we need to add ISR block diageam.

Why I can't see ISR block this Callback example code(TopDesign.cysch) ?!

Thank you so much.

Slave_ISR.JPG

0 Likes
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

Hi @Tim_Shih ,

This is because in this example code, the exit callback macro is enabled by defining the macro I2CS_I2C_ISR_EXIT_CALLBACK in the file cyapicallbacks.h as shown below 

AlenAn14_0-1638635806978.png

Also , for the I2C component, one thing to note is that the I2C component has the interrupts enabled by default (Because I2C  works based on interrupts to send the start , address, data , stop , ack etc bits in the source code with timeout of the same so user does not have to worry about these details and can directly use the I2C read and write API's) and its interrupts are handled in the function I2CS_I2C_ISR in the file  I2CS_I2C_INT.c as shown below:

AlenAn14_1-1638636063433.png

If you scroll to the bottom of this ISR function you can observe the macro definition check as shown in below image: 

AlenAn14_2-1638636166183.png

Since this macro is enabled in the cyapicallbacks.h file, the function I2CS_I2C_ISR_ExitCallback() , that is defined in main.c , will be called at the end of the I2CS_I2C_ISR handler. So the ISR block is not necessary for I2C component mainly because it is present by default.

Hope this explanation helps
Regards
Alen

 

Hi ~ Alan,

Do you mean this kind of interrupt don't need ISR control block ?!

That is to say, if I already set some interrupt "enable" in the code, then I don't need to create a new ISR control block in the *.cysch file, right ?!

Thank you so much.

 

0 Likes
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

Hi Tim,

Yes, the interrupts for the i2c are enabled by default so you do not need to create a new ISR control block in the *.cysch file.
The I2C ISR handler for the your I2C component will be present in the file <I2C component Name>_I2C_INT.c

For example, in below project image, my I2C component name is I2C_1, so the ISR handler will be in file I2C_1_I2C_INT.c

AlenAn14_0-1639412068893.png

 

Hope this helps.

Regards
Alen

ok ok, thank you.

0 Likes
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

Glad your  query is resolved. You can accept the response as the solution so we can close this thread.

Thank you for using our products and feel free to post any queries or issues you may have on our products in the community again :).

Thanks & Regards
Alen