Hello people,
I am trying to implement an I2C communication using interrupts. I want just to use Receive-data-ready interrupt and Transmit-data-ready interrupt. Unfortunately, they are not triggered as I was supposed them to do. I am using HalCoGen to generate the code. I have mapped the I2C interrupt to channel 62, I have enabled ICRRDY and ICXRDY in the I2C tab.
My initial goal is to send one byte and to receive one (using the interrupts), but the problem is that they do not look to be triggered at all. I have placed a breakpoint in my i2cInterrupt function and it does not reach this point. On the other hand, the right flags are set in the Interrupt Mask Register.
Let's say that I want an interrupt to be triggered when I send one byte successfully. I use this piece of code:
void main(void) { /* USER CODE BEGIN (3) */ i2cInit(); _enable_IRQ(); i2cSetSlaveAdd(i2cREG1, ADXL345Addr); while(1) { i2cSetMode(i2cREG1, I2C_MASTER); i2cSetDirection(i2cREG1, I2C_TRANSMITTER); i2cSetCount(i2cREG1, 1); i2cSetStart(i2cREG1); i2cSend(i2cREG1, 1, data_in); } /* USER CODE END */ }
What am I missing???
I attach this simple project in case you need to check anything else. I would really appreciate any suggestions, cause I am struggling for many days with this issue.
Kind regards,
Stelios
7271.i2c_Int.zip