I2C Interrupt

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

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hello,

   

I am in the process of developing communication between a Master device and a Slave device. In my Slave device code, I started off with having the I2C in the main() (polling). After several communication tests, I found that this is not desirable for my project. I then researched on I2C interrupt driven. The code I have attached is currently I2C interrupt driven but may not be implemented correctly. I have found results where my devices "hang" and don't respond to a command. I want to make sure that the slave receives the entire message from the Master, executes the command, and can safely receive the next command. Any help is appreciated. 

   

Thank you,

   

Rick

0 Likes
6 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Do not hesitate to ask Mrs. Wiki Pedia, she knows everything 😉

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hello Bob,

   

I'm not sure this is related to a hardware issue. My project use to work when my i2c code was in the main() (polling.). Now that it is in the intterupt handler, the program hangs. Do you know if this is the correct way to call the interrupt for an I2C?

   

Thanks,

   

Rick

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Sorry, my above post was misplaced and was an answer to a complete different thread. That should happen to my bank-account 😉

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Not a problem. Happens to the best of us haha...

   

 Would you happen to know how to properly construct an I2C interrupt?

   

Rick

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

What I would ask first (assuming it is a slave) "What will I be interrupted for?" When it is a simple read-one-byte-application the information to be returned can be set up in advance, so I must only be informed when the master has finished reading.

   

I would use the macro callback feature (Did you already update to Creator last version) and try to analyze the state the I2C is in.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

The Slave is intended for turning on LEDS and reading in various sensors which is why i went with I2C Interrupt instead of Polled I2C. My problem is properly writing the I2C interrupt. I have attached the project to this post if you would like to take a look.

   

Thanks,

   

Rick

0 Likes