PIC24FJ128GL306 data read issue

General discussion on mikroC PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
rasomaxa
Posts: 1
Joined: 12 Feb 2024 10:28

PIC24FJ128GL306 data read issue

#1 Post by rasomaxa » 27 Feb 2024 04:56

Hi,
I have done the I2C communication with the sensor but whenever I try to read the data from the buffer it is always showing FF.
Is there any pin that I should clear after getting the data to the buffer?

Code: Select all

unsigned int I2C_Master_Read_Byte(char ACKflag)
{

int t,temp,p[50];

I2C1CONLbits.RCEN = 1; //Receive enable

while(!DataRdyI2C1())
{
LATBbits.LATB2=~LATBbits.LATB2; // Only entering ones

}
temp=I2C1RCV;

if(ACKflag == 1) //Set state in preparation for TX below
{
I2C1CONLbits.ACKDT = 1;//NACK
}
else
{
I2C1CONLbits.ACKDT = 0;//ACK
}

I2C1CONLbits.ACKEN = 1;

sprintf(p, "temp : %d ",temp);
Oled_WriteString(p);

return temp;
}

int DataRdyI2C1(void)
{
return I2C1STATbits.RBF;
}

guardconie
Posts: 1
Joined: 11 Mar 2024 08:17

Re: PIC24FJ128GL306 data read issue

#2 Post by guardconie » 11 Mar 2024 08:19

The issue might be related to the acknowledgment flag or the timing. Ensure that you're sending the correct ACK/NACK after reading the data.x trench run You may also want to check the sensor's datasheet for any specific requirements regarding reading data. Adding delays or adjusting the timing could potentially resolve the problem.

Post Reply

Return to “mikroC PRO for dsPIC30/33 and PIC24 General”