CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

I2C interrupt on MASTER

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
silelis



Joined: 12 Jun 2007
Posts: 68
Location: Poland, podlaskie district

View user's profile Send private message

I2C interrupt on MASTER
PostPosted: Tue Oct 27, 2015 3:28 pm     Reply with quote

Hello,

I want to develop ROTS program which will support:
- TEA5767 I2C radio
- buttons (on port interrupt)
- other devices on SPI and i2c

As I said I consider ROTS but I am not sure how to handle I2C in this issue.

I mean:
If I will handle I2C communication in task there is possibility that task will be suspended by another task execution. Is it right?

I am consider if it is possible that in main loop or in same task I will make i2c communication start like:

Code:
main()
{
enable_interrupts (INT_I2C);
enable_interrupts (GLOBAL);
i2c_start();    // Start condition
i2c_write(0xa0);// Device address
// the rest of communication will be handle in interrupt function ??? is it possible??
}


but all the rest of communication will be handled by interrupt in i2c case:
Code:
#INT_I2C
I2C_HANDLE();

void I2C_HANDLE()
{
i2c_master_state=i2c_state(); //get slave ACK(s) and base on it handle all i2c communication?
switch (2c_master_state)
case ???:
- routine 1
case ???:
-routine 2
}


Is it possible? If Yes where I can find i2c_master_state values?

The idea which I want to achieve is like in this routine - see void I2C_IRQHandler(void) .
Ttelmah



Joined: 11 Mar 2010
Posts: 19553

View user's profile Send private message

PostPosted: Wed Oct 28, 2015 2:09 am     Reply with quote

The RTOS is _not_ pre-emptive. Your task will not get interrupted by another task. Each task has to finish, or yield.
You are worrying about something that won't happen.

However it raises the important point that when writing RTOS tasks, each _must_ be written to ensure that it does not hang. The I2C transactions will each take only a few uSec (a write, between possibly 20uSec and 80uSec assuming you are using reasonable I2C rates), but there is one condition that can cause a hang, which is that the I2C pull-ups are not present (or a device on the bus is hung).
Look at this thread:
<http://www.ccsinfo.com/forum/viewtopic.php?t=54523>
Obviously 'how' you handle this is down to your software/hardware, but it is a possibility that must be considered.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group