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 support@ccsinfo.com

Is polled slave I2C possible?

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



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

Is polled slave I2C possible?
PostPosted: Fri Nov 14, 2008 3:46 am     Reply with quote

Hi,

I am writing an I2C bootloader and I don't want the bootloader to use the interrupt vectors. I will just relocate them.

By not using interrupts, it would need to have the interrupt flag polled in the main loop. I don't know if it is fast enough to handle the I2C rate.

Have you done anything like this before? I need some sugestions.

Thank you.
Ttelmah
Guest







PostPosted: Fri Nov 14, 2008 4:18 am     Reply with quote

Done properly, this can be _faster_ than using the actual interrupt.
Basically, when the interrupt triggers, the processor 'calls' the main ISR vector. At this point, it has to save a whole 'suite' of registers, then test what interrupt flag has set, and that it has it's interrupt enable also on, to detect what interrupt has triggered. Only after doing all this, does it actually jump to the 'service routine'. Typically something like 30 instruction cycles occur from the moment the interrupt triggers to the point whre the routine is entered. If you declare the interrupt 'flag', using a bit directive, clear it, then simply sit waiting for it to go true, the response, will only be perhaps three or four instruction times after it triggers. Much faster...
Yes, this is a perfectly 'sensible' way to work, and works fine.

Best Wishes
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

PostPosted: Fri Nov 14, 2008 8:40 am     Reply with quote

The program does a lot more than the i2c comm and there are routines that take a few miliseconds to complete. That will delay the i2c handling and probably overflow the ssp register, am I right?
Ttelmah
Guest







PostPosted: Fri Nov 14, 2008 9:43 am     Reply with quote

Depends.
I2C, supports 'clock stretching', where the slave device holds the clock low, till _it_ has completed. You would need to enable this, and write your master code to wait till the slave releases the bus, while the 'slow parts' take place.

Best Wishes
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

PostPosted: Fri Nov 14, 2008 7:21 pm     Reply with quote

Yes, it works after the first byte is processed, but what if the master send a few bytes before the slave can process the first one?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Nov 15, 2008 2:59 am     Reply with quote

The discussion is somewhat bloodless without considering the actual application protocol. With a bootloader, the only time consuming action is erasing and writing to the flash. I assume that the bootloader data is buffered, then the I2C master may start programming of a block and do repeated status requests. No ACK to the request can be regarded as busy state.
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

PostPosted: Sat Nov 15, 2008 5:00 am     Reply with quote

FvM, you are right. I am confusing things. The loaded app will be complex... the boot loader will be a simple loop to receive bytes.
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