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.

Interrupt While Accessing I2C

Status
Not open for further replies.

Suraj143

Active Member
In my clock display scanning in the ISR. Every 4mS it’s going to ISR.

In the main routine every 1S I’m calling I2C.Note that I’m using software I2C as in nigels page.

Everything works fine.

But there is a doubt will this process hangs while accessing I2C if an interrupt occurs?

Code:
;=================================================================================		
;Read_EEPROM	; reads data from DS1307
;=================================================================================
I2C_Byte_Read	call 	I2C_Start
		movlw	b'11010000'		; slave address/write bit 0
		call 	I2C_Out
    		call 	I2C_NAK
		movf	E2_Add_Low,W
		call 	I2C_Out
    		call 	I2C_NAK
    		call 	I2C_Start		; repeated start condition
    		movlw	b'11010001'		; slave address/Read bit 0
		call 	I2C_Out
    		call 	I2C_NAK
    		call 	I2C_Read		; fetch the byte
    		call 	I2C_Send_NAK		; send no acknowledgement
    		call 	I2C_Stop
		movf 	InputByte,W		; return the byte in W
        	return
 
hi Suraj,
If the I2C timing is not within the ISR for the RTC and is being called using a delay loop, then the I2C will be interrupted when an ISR occurs.
 
Hi Eric my I2C routine is in the main routine.Display multiplexing is in the ISR.In the ISR I set a flag bit to read I2C.In the main routine I always check this flag bit & call the I2C routine if it is sets.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top