Hi this is vishnu.
i am trying to interface temperature sensor MLX90614. before doing this i have inerfaced 24c56 with PSoC sucessfully.
but when i am trying to interface with this itemperature sensor it is taking 9-10 startup p[ulses to get ACK (acknowledgement)
after that i am sending (0x07 which is a RAM adress of sensor ) here i am not getting ACK agian we need to send startup signal because of this it is keep on in that loop only.
i've thought there might be problem with I2C clock .
how we can fix this?
and even how we can get desired clodk for I2C?
i amattaching my project and datasheet of sensor
Solved! Go to Solution.
The below code is not correct. What you are doing is calling the bWriteBytes function again and again till the WR_COMPLETE flag is set.
while (!(I2CHW_bReadI2CStatus() & I2CHW_WR_COMPLETE))
I2CHW_bWriteBytes(0x00, (char*)&ReadAddress, 2, I2CHW_CompleteXfer);
I2CHW_SendStop(); // Send stop to terminate the previous interaction
Inside the same loop, SendStop is being called as well. This will totally mess up the transactions and will never let the Write transaction to complete.
Let me know what transaction you are trying to do with the sensor (reading from a particular location or writing to a particular location) and I will provide you with the code snippet.
The PSoC Hacker
Hi sir thanks for the reply.
Sir i am trying to read temperature value which is available in RAM adress 0x07. now here i am including new modified c file and application note of the sensor. In this application note in page no 16 they provided a flowchart according that now i've written code. in this i am not getting any acknowledgement the sensor. Master device (PSoC) continuosly sending start signal.
how we can change the I2C clock?
Thanks and regards
I think there is no need to follow the flow chart as it is. There should be no problem with the Slave sending an ACK to the Master's transactions. So, you can use the high level APIs bWriteBytes and fReadBytes to write the command and read the temperature from the sensor. I have modified the project to write a command 0x07 and read 3 bytes of data from the slave. See if this works. Try to understand how the high level APIs are used. That will help you to implement other read/write operations with the slave successfully.
Without the hardware, it is very difficult to guess what the problem could be. But I am sure you have to use the logic similar to the one I have used in the program. Do some other debugging. Check if the pull up resistors are fine on the SDA and SCL lines. Try calling the fSendStart and SendStop functions continuously and check with the logic analyzier if the slave ever acknowledges the address. If it does not, then there should be some other problem.
i've interfaced same sensor with "MBED nxp LPC 1768" sucessfully. but coming to PSoC i am not getting the acknowledgement. even with MBED board also i am getting perfect output at 20khz I2C frequency only . if i chnaged the frequcny i am not getting the acknowledgment there. thats why i am trying to know how to change the I2C clock in PSoC.
here i am including MBED code also.
Thanks and Regards
There is a parameter called I2C Clock in the I2CHW settings. You can select 50KHz for I2C clock and try. Also, first use only the fSendStart function repeatedly and see if you are getting an ACK from the slave. Remove all other code and use the below code.
I2CHW_SendStop(); // Send stop to terminate the previous interaction
The above code will keep loopin till the slave issues an ACK. Analyze this with the logic analyzer and let me know if you get an ACK at all.
hi i've tried those settings which are available 50,100, 400 but no use.
the code line which you sent i've tried that this before , i am getting acknowledgment after 9 write operations (some times).
is any other way to get custom clocl for I2C?
Thanks & Regards
Please find attached the project that works on PSoC3 device with MLX90614. You might want to use PSoC Creator software to view the same. For your benefit i have attached the "main.c" file separately.
Please note that i was facing the issue that you are facing, that is no ACK from Slave(MLX sensor). I held the SDA line low for about 10ms and then started issuing I2C commands, it started working. You need this pulse to enter SMBUS operation.
sorry for the delayed reply . first thanks for providing the details about your project. i ve tried that but i am unable to obtain output.
I have written a software I2c to get the results.i am able to get acknowledgement from sensor , but unfortunately the data which i am getting is not correct(while reading). always it is a fixed value.
thanks & Regards
Upon power up the MLX90614 module will be reading the temperature data held in RAM address 0x07. There is a minimum 1 ms delay between each temperature reading. In the non-sleep operation mode the timing is adjustable from 1 to 2550 ms and can be set in the low data byte of the reading time interval command address (0x21). In the sleep operation mode the timing is adjustable from 1 to 255 seconds and can be set in the high data byte of the reading time interval command address (0x21). It takes approximately 1 ms to perform a temperature reading. Interval timing for non-sleep and sleep operation modes have been factory set at 50 ms and 1.15 seconds, respectively.
Esure proper delays between read operation. Register 0x06 gives ambient temperature and register 0x07 gives object temperature. Try reading both registers to see the variation.
I am trying to interface MLX90614 with PSOC 4 BLE. With reference to above code I have made necessary changes, but I am not able to read the data. Can anyone please help me out.
This is my code
//uint16 pec = 0;
//double tempFactor = 0.02;
// 0.02 degrees per LSB
double tempData = 0x0000;
//uint16 data_low = 0;
//uint16 data_high = 0;
//This converts high and low bytes together and processes temperature,
//MSB is a error bit and is ignored for temps
// This masks off the error bit of the high byte, then moves it left 8 bits and adds the low byte.
//data_low = rdBuf;
//data_high = rdBuf;
//pec = rdBuf;
/*tempData = (double)(((data_high & 0x007F) << 😎 + data_low);
tempData = (tempData * tempFactor)-0.01;
tempData = tempData - 273.15; */
Welcome in the forum, Likhitha.
You are a bit wrong here, this is a PSoC1 forum and you have got a PSoC4 or PSoC4 BLE problem. It can turn out that none of the guys that have the knowledge read your post.
Can you post your complete project, so that we all can have a look at all of your settings? Makes it much easier to find the cause. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Some comments on I2C.
Use pins P5_0 and P5_1 for I2C. Pullups are already installed. The P3 pins are connected to the KitProg on the board.
A delay after read and write I2C is not needed
Don not send an additional stop() command.
The WriteBuf() function returns a status, check that for a successful transfer before reading.
Comments on UART
Use pins P1_5 and P1_4 for UART. These are connected to the Kitprog which will act as an USB-UART bridge emulating a com-port on the windows side. You will see that com-port in windows device manager. Connect PuTTY with the correct baud rate to that port.
You are sending binary data (int, uint) to UART, these are not printable. Use sprintf() to convert the data to strings and send the string over UART. under Project->Build settings-> linker is an item to allow for float formatting, use that when memory usage allows. In .cdwr view, system tab increase the heap size to at least 0x0100,