IIC busy flag always set after IIC enable as master

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IIC busy flag always set after IIC enable as master

Jump to solution
862 Views
ppd
Contributor II

Hi,

I hope someone can help me with this issue I am struggling with for the last couple of days.

Hardware: QG8 with 5.6K pull-up resistors on both SCL and SDA.

Software:

void main(void) {
  MCU_init();

  IICC = 0x00;
 
  IICC_MST = 1;
  IICC_IICIE = 1;
  IICC_IICEN = 1;
 
  while(IICS_BUSY) { }
}

Problem:

After line "IICC_IICEN=1" IICS_BUSY is set and never cleared. Is this normal? If so, how can I clear it? If it is not OK then what am I doing wrong?

This happens only if I set the master bit (i.e "IICC_MST = 1"). Currently there is no other device in the system, just my QG8 with it's pull-up resistors.

Thank you!

Paul.

Labels (1)
0 Kudos
Reply
1 Solution
583 Views
kef
Specialist I
  •  Is this normal?

Yes. You are not just switching slave<->master, setting MST bit generates start condition on the bus. BUSY just tells you if bus is free, = that no master (including your own node) generated start condition, both IIC lines are not driven low. Of course bus is busy when MST is set.

View solution in original post

0 Kudos
Reply
3 Replies
584 Views
kef
Specialist I
  •  Is this normal?

Yes. You are not just switching slave<->master, setting MST bit generates start condition on the bus. BUSY just tells you if bus is free, = that no master (including your own node) generated start condition, both IIC lines are not driven low. Of course bus is busy when MST is set.

0 Kudos
Reply
583 Views
ppd
Contributor II

Ah, I see...

 

Thank you, kef!

0 Kudos
Reply
583 Views
ppd
Contributor II

More info.

 

I also have an interrupt service routine:

 

interrupt 17 void Viic_isr(void){

  IICS_IICIF = 1;
           
}

 

Before the interrupt service routine is called, IICS is 166 (i.e TCF, SRW and IICIF are set). After acknowledging the interrupt IICS reads for one cycle 164 (i.e TCF and SRW are set) after which it becomes 166 again and the process repeats itself.

0 Kudos
Reply