- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
Is there an example source code for I2C master using Interrupt?
Please refer to below.
- IDE : PSoC Creator 4.2
- PSOC4200L
- I2C SCB
- I2C Master example using interrupt
a. transfer
When the Tx start interrrupt flag is triggered, then I2C ISR starts transferring rest of the data.
b. receive
If there is data in the I2C rx buffer, then the data is transferred from I2C Rx FIFO to the user defined buffer by the ISR.
Thanks and Regards,
YS
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi YSJE_3566666
Since the master initiates the read and the write command, an interrupt is not required. You could have a timer interrupt that periodically calls the read and write commands. But the slave will not write to the master's Tx buffer unless the communication is initiated by the master.
So the implementation is that you read the packet by calling the I2CMasterReadBuf API and transfer to the buffer directly. The API takes the buffer as a parameter.
Best regards,
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi YSJE_3566666
Since the master initiates the read and the write command, an interrupt is not required. You could have a timer interrupt that periodically calls the read and write commands. But the slave will not write to the master's Tx buffer unless the communication is initiated by the master.
So the implementation is that you read the packet by calling the I2CMasterReadBuf API and transfer to the buffer directly. The API takes the buffer as a parameter.
Best regards,
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Hari,
Thanks for your reply.
Except for the a/b situation I mentioned, are there any other examples using interrupt?
There is something I want to test by referring to an I2C interrupt example.
Thanks and Regards,
YS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello YSJE_3566666
These interrupts are handled internally and you don't have to process in your application. You can, however, have your custom function if required by defining the variable I2C_SCB_IRQ_INTERRUPT_INTERRUPT_CALLBACK in cyapicallbacks.h and defining the function I2C_SCB_IRQ_Interrupt_InterruptCallback(). Please see the ISR present in I2C_SCB_IRQ.c file.
Best regards,
Hari