- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Solved! Go to Solution.
- Labels:
-
PSoC 4 MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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:
If you scroll to the bottom of this ISR function you can observe the macro definition check as shown in below image:
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Hope this helps.
Regards
Alen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ok ok, thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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