LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I2C with ARM embedded receiving incorrect data

Solved!
Go to solution

Hi together

 

For a schools project, which I must finish until next week, I need to read out a DS1307 RealTimeClock via I2C.

 

I am using a LM3S8962.

 

I have tried to communicate via the NI USB-8451 module, which worked just fine.

Now I only need to read out the Data from the DS1307 and I used the ARM embedded I2C VIs. I receive some data, but the Data is not correct (for example it shows a value of 70 in the seconds-register which is not possible).

I've tried a lot of things but I couldn't get it to work properly.

 

Attached a screenshot of how I implemented the reading of I2C. What am I doing wrong? I have really to get this working otherwise I can't finish my project and this would unfortunately result in a bad mark 😞 I hope someone can help me.

 

Regards from Switzerland

 

Dominic

 

 

0 Kudos
Message 1 of 5
(2,914 Views)
Solution
Accepted by topic author doh

Hi doh,

 

are you sure you are reading from the right register? 

 

According to this datasheet: DS1307.pdf , 

 

if you want to access the seconds register it would be Adress 0 (Hex-Value-0), in your screenshot its 68 decimal. You can change the representation of your constant which is connected to the Adress terminal of your Create Configuration Reference VI. Just right click your constant -> visible object -> Radix. After that you can change the representation to x (HEX).

 

Additionally when you read the 7 bits which are casted to 8 bit unsigned you have to notice that the 7 bits are encoded as BCD code.

 

So consider your example reading the value 70: 70 in binary means: 100110 with the most significant bit on the left side and the least significant bit on the right side. Now when you split the values according to the seconds in the datasheets table:

 

 

| 0 | 1 0 0 | 0 1 1 0  

 

Then you will see, that 70 as U8 value has : 0110 = 6 (last 4 bits) and 100 (middle 3 bits) = 4, which means, that your actual value is not 70, but 46.

So I would guess, you have to convert the U8 value to an Boolean array, split the bits according to the Table mentioned in the manual and then convert them to the proper time.

 

Hope this helps, if you have further questions just post.

 

With best Regards,

Lam

0 Kudos
Message 2 of 5
(2,860 Views)

Thank you for your answer. I could resolve the problem by converting the Adress from decimal to hex. This solved the problem.

 

Regards

Dominic

0 Kudos
Message 3 of 5
(2,840 Views)

Hi doh,

 

thanks for your response. Glad I could help you. And good Luck with your application 😃

 

Best Regards,

Lam

0 Kudos
Message 4 of 5
(2,835 Views)

Good day everyone,

 

I am trying to do the same thing~ after i read the comments i have understand more about it.. unfortunately I still can't get the data. The 'data read' is always 255 (which is not suppose to get). Is there anything incorrectly drawn in my block diagram? Smiley Embarassed

 

What actually should i connect to the 'write data'? I just put '0' connected to the 'build array', is it correct? 

 

Best Regards,

Kent

0 Kudos
Message 5 of 5
(2,663 Views)