This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

I2C functions issue

I am emulating a code based on the I2C slave application note from Philips. What happens is my the microcontroller (LPC762)start locking the bus as soon as the I2C slave functions get activated by setting I2CFG register to slave or a master configuration (values 9xh or 8xh). I don't know what the micro is doing to the I2C bus (which seems to have the SDA and SCL high though). The bus stops responding to query from a different master right after excuting the "mov I2CFG, #80h" instruction. Am I missing anything to configure before setting the I2CFG register in the code below:
;

  						Main program
;-----------------------------------------------------------------------------			

Reset:					mov		SP, #2Fh		; Set stack location
					mov 		R0, #TxData		; Set up pointer to Tx data area
					mov 		R1, #MaxBytes		; Set up buffer lenght counter
RLoop:					mov		@R0, #0FFh		; Initialize buffer memory to 1's
              				inc		R0			; Advance to next buffer position
               				djnz		R1, RLoop		; Repeat untill done               



; 				Initialize comparator 1 and 2	
;------------------------------------------------
; Comparators have to start up for at 
; least 10us before use. The 10 us delay is
; garanteed by the instrcutions cycle time 
; running after enabling the comparators
;------------------------------------------------				
CmpInit:														
					mov		PT0AD, #14h		; Disable digital inputs on CIN1A and CIN2A
					;anl		P0M2, #0cfh		; Disable digital outputs
					;orl		P0M1, #30h
					mov		CMP1, #28h		; Turn on comp 1
					mov		CMP2, #28h		; Turn on comp 2 
					anl		CMP1, #0feh		; clear comp 1 interrupt flag
					anl		CMP2, #0feh		; clear comp 2 interrupt flag
					clr 		EC1			; disable comp 1 interrupt
					clr		EC2			; disable comp 2 interrupt
					
					mov		P1M1, #02h		; Set pin 1 in port 1 to input only mode
					mov		P1M2, #00h		; other port 1 pins to Quasi-bidirectional mode

; 				Fill in the Expanders address table	
;----------------------------------------------																	

					
               				mov      	ExpTable, #Exp1_Add  
               				mov		ExpTable + 1, #Exp2_Add
               				mov      	ExpTable + 2, #Exp3_Add
               				mov      	ExpTable + 3, #Exp4_Add
               				mov      	ExpTable + 4, #Exp5_Add
               				mov      	ExpTable + 5, #Exp6_Add
              				mov      	ExpTable + 6, #Exp7_Add
            				mov		ExpTable + 7, #ExpVM_Add 


; 				Set up interrupts	
;----------------------------------------------										
					
               				mov		AdrRcvd, #0		; Clear address received
               				mov		Flags, #0		; Clear system flags
               				setb		EI2			; Enable I2C interrupt
               				setb		ETI			; Enable Timer 1 interrupt
               				setb		EA			; Enable interrupt system
               				mov		I2CFG, #BSLAV+CTVAL	; Enable slave functions = 80h
               				mov		I2CON, #BCSTR+BCSTP+BCXA+BCDR+BCARL+BIDLE	; Put slave into idle mode
               				setb		TIRUN			; Turn on Timer I


; 				Main Loop	
;----------------------------------------------

MainLoop:				ajmp

0