Introduction

Hello, I'm Dophie.

After the production practice, the full-scale OJT finally started.
Even though I am not used to it, I feel that I am growing day by day by accumulating interactions with customers.

Last time, I finished with the trouble that "acknowledge" was not returned in I2C communication.

Now let me show you how I solved this problem.

Process 1 ~ Reconfirmation of the goal ~

First, I calmed down and confirmed what I was trying to achieve (the goal).

<Goal of this time>
"Microcomputer and D/A converterI2C communication is performed, and data is sent from the microcomputer to the D/A converter.
D/A convert the data and finally output it as an analog voltage.


This is the final goal, and what I'm currently struggling with is the I2C communication between the microcomputer and the D/A converter at the beginning.

■ Calmly analyze the situation

This is also an important thing that I learned in the production practice.
When things don't go well and you can't see your surroundings because you're in a hurry, it's important to calm down once.

Process 2 ~Confirmation of the program~

First, I reviewed the written program.
(A microcomputer board called Genuino101 is used in this production practice).

Figure 1 shows the actual written program.

Figure 1 Program Written in Genuino (Before Solution)

Genuino101 programming is based on C++, but there are some languages that are dedicated to Genuino101, so I will introduce some of them below.

・void setup (): A function that processes only when the power is turned on and reset.
・void loop (): The main processing function that is repeatedly executed.
・Wire.begin ( address ): Initialize the Wire library. Connects to the I2C bus as master or slave.
・Wire.beginTransmission ( address ): Start transmission processing to the I2C slave at the specified address.
・Wire.write ( value ): Used when the slave transmits data in response to a request from the master.
- Wire.endTransmission (): Complete transmission to the slave device.

※remarks
The data in () of Wire.write is set so that the D/A converter outputs 1 V.
(using the formula given in the LTC2631A-12 data sheet)

We reviewed the program in Figure 1 and identified the part that caused the problem.


First, the address ( 0x20 ) specified by Wire.beginTransmission ( adress ) is
Isn't it compatible with the slave address ( LTC2631A-12 )? I thought (the part surrounded by the red frame in Figure 1).

However, I didn't understand anything, so I read the datasheet many times and reconfirmed the principle of I2C communication.

Process 3 ~ Re-reading the data sheet and understanding the principle ~

After reading the datasheet over and over again, I thought.
"I wonder if it's not wrong after all...".

Figure 2 shows a typical LTC2631 write transaction.

Figure 2 LTC2631 Typical Write Transaction (Source: LTC2631 Datasheet)

Looking at the SDA in Fig. 2, the slave address is "00100000 (hexadecimal: 0x20)" with "0" assigned to the 8th bit, which is the write designation bit, for "0010000" of A6 to A0 (7bit). No doubt.

Then why is the acknowledge not returned...

" by the way! "
There was another anomaly.
(The data "00100000" should have been sent, but the waveform shows "01000000": see Figure 4 in the previous article)

I thought, "This is it!" and read the data sheet again. I found a diagram that caught my attention (Fig. 3).

Figure 3 Command and Data Input Format (Source: LTC2631 Datasheet)

Notice before SLAVE ADDRESS.

This is my honest opinion at the time.
"What is S!!!"

After investigating, I found that this S is the start bit.
I2C communication starts when SCL is high and SDA is low (see Figure 2).
Both SCL and SDA are pulled high through pull-up resistors when communication is not in progress.

When you want to start communication, send S (start bit: Low) to create the state of SCL: High and SDA: Low.

The cause was the principle of starting communication, which is the most basic of I2C communication.
After a long detour, I found the cause.

I also learned two things here.

■ Some clues and answers are hidden in the data sheet
■Understanding of basic principles is most important

Process 4 ~ Acknowledgment return completed! ! ~

Now that we know the cause, all that's left is to fix it.

In other words, shift "00100000 (0x20)" to the right by 1 bit to put the start bit in the 1st bit.
Then "00010000 (0x10)" is the correct addressing.

Convert the contents of Wire.beginTransmission() to (0x20 → 0x10) with the program in Figure 1 and write it to Genuino101.
Figure 4 shows the observed waveforms.

Figure 4 SCL and SDA (after successful communication)

Looking at Figure 4, you can see that SDA is output in the order of SLAVE ADDRESS, 1st DATA, 2nd DATA, and 3rd DATA as shown in Figure 2, and acknowledgments are returned between them.

In retrospect, the problem could have been solved by changing just one character in the program, but it took a lot of time.
However, I think that it was an event where I was able to realize my growth by hitting many walls.

at the end

Previously, Major Leaguer Ichiro said this on TV.

"Even if you don't make mistakes and get there without making any mistakes, you won't get any depth.
In retrospect, it's very important that it was a waste of time.
The detour is the best shortcut. ”

I was able to embody exactly this word in the production practice this time, and one of them was the experience of this article.
Someday, I want to make a name like this.

In this way, I2C communication was successfully established, and the D/A converter could be controlled by the microcomputer.

Wiring according to the circuit diagram with conductors = Communication is possible

I miss the time when I thought...

Thank you for your next article. Finally, we would like to introduce the analog IC manufacturers that we deal with.

Analog Devices

A leading manufacturer of high-performance standard analog ICs.
We determine the performance and quality of our customers' final products, such as amplifiers, battery management, data converters, high frequencies, interfaces, voltage regulators, and voltage references, and achieve stable supply.
In principle, we will not discontinue the production of our products, so customers who use our products for a long period of time, such as industrial equipment, can use them with peace of mind.

<Analog Devices detail page>