2003-10-30 08:21 PM
2003-10-29 05:38 AM
After spending some days of unsuccessful experiments i need urgent help.
We use the I2C at Slave mode. After receiving the Address match and the ADSL flag become '1' Then, reading of the SR1, SR2, and DR to reset ADSL, and here is the problem after ADSL flag is go to '0' , the BTF and TRA become immediately '1', without any activity at the I2C bus. The ways I found to reset them are: 1) writing to DR, 2)up and down the STOP bit and 3)disable the I2C by take PE '0'. Why do I get these flags at all?2003-10-29 08:35 AM
Hi Latino
My I2C interrupt service routine looks like this: #pragma asm sim; /* mask interrupts */ #pragma endasm copy_of_I2CSR1 = I2CSR1; copy_of_I2CDR = I2CDR; copy_of_I2CSR2 = I2CSR2; do your processing on the register copies here #pragma asm rim; /* unmask interrupts */ #pragma endasm This routine works for both slave receive and master transmit. Hope this helps BM2003-10-29 08:36 PM
Hi BM
I have try the suggested sequence of commands and its stays the same. after initialization, when the i2c bus send my address, the st7 identifies the match and take ADSL flag high. Immediatly after i read the I2CST1, I2CDR and I2CST2 to copy of them, (as instructed) Instead of make EVF & ADSL '0' and leave BUSY '1', the st7 make ADSL '0' and EVF, BTF,BUSY, TRA '1' - of course this is incorrect because the I2C bus didn't recieve or transmit anything in 10 uS time !! help please..... sory about the long explanation but i try to make things clear. regards room2003-10-30 08:28 AM
Hi
It is strange that TRA == 1. This is saying that a byte has been transmitted. If you are using interrupts rather than polling, make sure interrupts are masked while you are servicing them. Here is my initialisation routine for the I2C port: I2CCR = 0x00; // Force reset I2COAR2 = 0x40; // Fcpu = 8MHz FXtal/2 I2CCCR = 0x26; // I2C clock rate = 100kHz I2CCR = PE; // Enable port I2CCR = PE|ENGC|ACK|ITE; // Config: port enabled, general call enabled, acknowledge enabled, interrupt enable #pragma asm rim; /* unmask interrupts */ #pragma endasm2003-10-30 08:21 PM
Hello BM
Thanks for the replay, But, .... As I say at my previus note the incorrect signals in SR1 are apeared immediatly (whithin 3 to 10uS) )after I reset the ADSL. So, the BTF and TRA aren't signaling for real I2C cycle that happend but it is an incorrect and faulty signals. The some problem happend in interrupt mode and in polling mode I have tried both of them. I use logic analyzer to watch the exact content & timming of signals of the I2C bus versus the SR1 register. This phenomena is quiet stable for all my expriments of the previus week and yes, I tried to replace the chip to new one. Help !!!! thanks room