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.
Solved! Go to Solution.
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.
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.
Ah, I see...
Thank you, kef!
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.