Quantcast
Channel: EngineerZone: Message List
Viewing all articles
Browse latest Browse all 28044

Problem in communicating ADuC7020 with LM75A temperature sensor via I2C

$
0
0

Hello,

I am using ADuC7020 evaluation board.I have additionally placed two LM75AIM temperature sensor ICs using 10K pull-up resistors.I am trying to communicate using I2C to the sensors and read the temperature and product ID of both the ICs.(so, both are READ operations).

Steps I have followed:

Step 1:

I have configured GP1CON to 0x00000022 inorder to use I2C0 (SDA0 and SCL0 lines), I2C0CFG to 0x0082, I2C0DIV to 0xCFCF

Step 2:

Both the operations are READ (i.e reading the temperature and reading the product ID). Initially when I have to select a slave using the slave address, I have to transmit the same onto the I2C0ADR register.The LSB of this address specifies if its a read or write operation.

In my case, I have pulled the A2, A1, A0 lines high for Temperature sensor 1 and pulled low the A2, A1, A0 lines for temperature sensor 2.

So, the corresponding addresses are 0x90 (Write operation in Temperature sensor 1)

                                                      0x91 (Read operation in Temperature sensor 1)

                                                      0x9E (Write operation in Temperature sensor 2)

                                                      0x9F (Read operation in Temperature sensor 2)

I have assigned the corresponding address to I2C0ADR register which selects the correct slave I guess.

Step 3:

I have to set the pointer register of the selected temperature sensor to 0x00 (to read the temperature) or to 0x07 (to read the product ID of LM75AIM, which happens to be 0xA1).

 

Doubts are as follows:

Inorder to send the value of pointer register, I have to send the corresponding value ( 0x00 or 0x07) to I2C0TX register.For doing this operation, should I initially set the R/W in the address in STEP 2 to WRITE and later again send the address using I2C0ADR with the READ bit turned on inorder to read the output value being sent from the slave (temperature sensor).

 

I have followed the steps which I had asked as doubt but the value 0x07, doesnot get assigned to I2C0TX register initially when i tried assigning it directly.The value doesnot get written initially.Only at a later point,it gets assigned, which makes the returned result value being wrongly stored in the variables allocated.

 

Any help in this matter would be of great help.

Thanks in advance.


Viewing all articles
Browse latest Browse all 28044

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>