I'm working on T1042RDB board and I'm writing I2C driver as standalone but i have encountered some problem during writing driver. before i tell my problem, i want to show some part of the driver code.
the following is initializion step in the driver for master.
I2C_Frequency->FDR = 0x1;
I2C_Dfs-DFSR = 0x1;
I2C_Control->MTX = RECEIVE MODE.;
I2C_Control->MEN = MODULE_ENABLE;
after above initilazation, i call my readFromSlave function which it sends START Condition, and Slave address with R/W bit.
readFromSlave function is like that;
if(I2C_Status->MBB == BUS_AVAILABLE)
{
I2C_Control->MSTA = MASTER_MODE;
printf("I'm master from now\n");
}
I2C_DATA->Data = SLAVE_ADDR && MASK_WRITE; // slave addres is 0x4c and mask_write is FE.
while(I2C_Status->RXAK != ACKNOWLEDGE_SIG); //ACKNOWLEDGE_SIG is 0.
when i call readFromSlave function, "while loop" is not broken. slave is not sending ACK message to master and i know this ACK means slave says "yes, this address belongs to me and i'm on the bus".
i wonder that why slave is not sending an ACK to master. by the way, i guess in the terminology this ack belongs to address cycle.
how can i resolve this problem because slave doesnt send ack to master ?
thanks in advance.
i found the reason of the problem. It was about calculation of slave address .
thanks.
I just want ask you to check SDA signal but found you has solved problem. I am glad.
It looks like you want to write address to slave while keep master in receive mode "I2C_Control->MTX = RECEIVE MODE.;"
Select master mode (set I2CCR[MSTA]) to transmit serial data and select transmit mode (set I2CCR[MTX]) for the address cycle then write the slave address being called into I2CDR.
Thanks sergeui for your reply but the problem is same. i set MTX to transmit mode for address cycle but slave is not sending address ack to master.
you have any recommend to try ?
thanks in advance.