i2c, reading one byte - transmition stops

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

i2c, reading one byte - transmition stops

2,348 Views
przemula
Contributor I
Hello
Under is my script that i've written to read from CMPS03.
I've a problem because when I'm trying to read from CMPS03 the transition stops and I dont know why.

PORTA_BIT0=0;
while(IBSR_IBB==1){
}
PORTA_BIT1=0; //first LED off
IBCR_IBEN=1; //I-Bus Enabled
IBCR_MS_SL=1; //HC12 is Master
IBCR_TX_RX=1; //Transmit mode

IBDR=0xC0; //sending the address of cmps03
while(IBSR_IBIF==0){
}
if (IBSR_RXAK==0) //control for acknowledge received
PORTA_BIT2=0;
IBSR_IBIF=1;

IBDR=0x01; //sending the number of register i want to read from
while(IBSR_IBIF==0){
}
if (IBSR_RXAK==0)
PORTA_BIT3=0;
IBSR_IBIF=1;

IBCR_RSTA=1; //repeated start

IBDR=0xC1; //sending the address of cmps03 with R/Wbit
while(IBSR_IBIF==0){
}
if (IBSR_RXAK==0)
PORTA_BIT4=0;
IBSR_IBIF=1;

IBCR_TX_RX=0; //received mod
IBCR_TXAK=0; //transmit akc will be send

while(IBSR_IBIF==0){ //waiting for receive to complete

**************************************
* In this loop the transmition stops *
**************************************

}
IBSR_IBIF=1;

polozenie=IBDR;

IBCR_MS_SL=0; //sending stop bit

PORTA=0xFF;
Labels (1)
0 Kudos
Reply
2 Replies

1,029 Views
rhinoceroshead
Contributor I
I had a problem like this once - where the first byte would come in perfectly, but then all consecutive bytes would be 0xFF.  I was giving a 1 as an ACK instead of a 0 by mistake.  The device noticed that I was not acknowledging so it stopped transmitting.  I was not using an IIC module and was bit-banging on an HC08 without IIC.
0 Kudos
Reply

1,029 Views
imajeff
Contributor III
When I had this problem it was a failed MCU pin. The slave side was unable to pull SDA low for the ACK, even though the slave correctly received the first byte.
0 Kudos
Reply