Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

I2C Master using Interrupts - design question

Status
Not open for further replies.

electroRF

Member
Hi,

I wanna enable the I2C Interreupt in the Master.

My difficutly is, how would I design my Main Function and ISR Function?

I mean, say that your application wants now to transmit 5 bytes to Slave.

How would you design the Main and ISR functions, so the Main can do other things between the bytes transmissions, and not wait until each byte is transmitted?

I can't imagine how I design it.

Thanks!
 
What microcontroller?

He'll be using the pic18 as the other thread mentions the interrupt vector 0x0008...

The only interrupt available to you is the SSPIF but it is complex to be used in that manner.

The following events will cause the SSP Interrupt Flag
bit, SSPIF, to be set (SSP interrupt, if enabled):
• Start condition
• Stop condition
• Data transfer byte transmitted/received
• Acknowledge transmit
• Repeated Start

This means your ISR will be larger than you need as you will have to check each condition.
Large ISR routines are not a good idea.... You can do a sequential write within 6ms... The 6mS is including the time for housekeeping.

Why do you need to use interrupts? I never use interrupts with I2C transfers.
 
Why do you need to use interrupts? I never use interrupts with I2C transfers.

That is a good point. I always use interrupts with rs232 communication, but I don't remember ever using interrupts with i2c. It seems that if you have i2c devices in your system, then the overall system is not that time-critical.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top