#259 No wonder you don't have a girlfriend

Wrong mailing address? Strictly speaking, if the IIC bus in the single-chip system wants to connect multiple chips in series, the most basic command operation process is to send the device address, the internal operation address of the device and the command that needs to be operated.

MPU9150 this gyroscope is to induce the acceleration of each axis through the change of the internal magnetic field relative to the geomagnetic change, and the AD value of the voltage changed due to the change of the magnetic field can be directly read through the guò IIC bus, and the AD value has four groups, these four groups of numbers jù are called quaternions, after reading these numbers jù, after filtering and Euler angle fusion calculation on the software, you can get the attitude on the XYZ axis in the three-dimensional space of the chip, and at the same time, you can also get the acceleration and angular velocity in the direction of the three dimensions.

At the same time, it is also possible to read the fifth group of numbers jù through guò to obtain the corresponding geomagnetic orientation angle of the electronic compass.

To complete this qiē, you need to find the device address first, and then send instructions to the relevant registers, and then the chip will return the number jù.

However, because the MPU9150 chip also comes with a digital jù processor inside, the name is DMP, which is the motion processor, which can directly help the processor complete the quaternion attitude fusion process that consumes a lot of computing resources, and directly return the three-axis attitude angle, three-axis acceleration, three-way acceleration and geomagnetic angle to the processor. It's a handy and powerful tool.

However, in the official reference, the address with the chip is provided. However, it is also divided into two addresses, the DMP processor and the direct reading of the quaternion AD value. The two addresses have different registers and control commands. Lan Zeguang found that this senior Dong Chen used a transplanted program, which used guòDMP to read the number jù. However, the macro definition of his device address is written on the MPU9150 of the quaternary numerical control address.

Well, having said all this, Lan Zeguang just wants to show one thing: that is, Senior Dong Chen, you are indeed mistaken.

"How is that possible!" He stood up and looked like he was about to tear up with Lan Zeguang.

However, the wheel is weak, how can he, a weak chicken program dog who lacks exercise all year round, be able to shake Lan Zeguang?

"It's impossible to change it!" Lan Zeguang smiled with a challenged smile. Then I typed a few times on the keyboard, changed the device address of the program's precompiled macro, and then pressed the compile button.

"Damn, I told you not to change my program. Can you change it back later? What are you messing with%! #¥@……”

The latter words are automatically ignored by Lan Zeguang. Although it can't be said that people are funny, Lan Zeguang understands the happiness of a programming ape, and generally doesn't want others to change the program he worked so hard to write. However, when Lan Zeguang saw this program, there was a lot of English staring in it. I knew it was a transplant.

Although transplantation also takes time. But at least it won't be that hard......

Lan Zeguang was disdainful, and at this time the program compilation was completed. 0error,9warning,Although there is a warning, the program should work. So Lan Zeguang clicked loading easily, and the program that could be debugged was downloaded to the single-chip microcomputer. Once reset, you can see the effect.

However, nothing worked!

“…… Did you see that? It's useless for you to change things around. Hurry up and change it back! The senior was excited again, and then he reached out to pull Lan Zeguang's shoulder. A violent look.

"Maybe you're having a problem with your transplant, senior?" Lan Zeguang shrugged his shoulders, moved his shoulders, and slapped his hand away.

"Don't make a fuss, how is it possible!" Senior Dong Chen continued to stretch out his hand, not pitying the jade at all, wanting to push Lan Zeguang away.

"How can't it be, I'll take a look!" Lan Zeguang said confidently, and then pushed the senior away again.

"Lying ...... This is my place, junior, hurry up! When the time comes, I'll get the program right, and the transplant will be normal, I'll give you a good one! Seeing that he couldn't fight Lan Zeguang, this obstacle sighed like a collapse.

"I'm going to study it anyway, I'll take a look first." Lan Zeguang glanced at him, and then propped up the table, staring intently at the senior's screen. The senior was about to go crazy, and once again he grabbed Lan Zeguang's shoulder and said, "Hey! Your name is Lan Zeguang, right? Don't think I'm afraid to hit you if you're a woman! ”

"......" For the acer program ape with less than half a goose in combat power, Lan Zeguang is not afraid of him at all. While staring at the screen for bugs, she teased the senior, saying, "Senior, it's no wonder you can't find a girlfriend when you're always like this." It is said that the programmer ape does not have a girlfriend, is it because of your strange temper? If you add the identity of acer, you won't have a girlfriend! ”

No, Lan Zeguang glanced at the video that the senior watched on ACFUN, it was Van's♂ FA score, he didn't open it, but it was estimated that the sound in the headphones would be very pleasant.

It is said that the fact that ACER does not have a girlfriend will give you ACER a blow to your heart, and the same is true for Senior Dong Chen. He was complained about by Lan Zeguang, and immediately held his forehead as if he thought of something. Is he introspecting? No, if he doesn't have a girlfriend, he doesn't have a girlfriend, so he won't reflect on anything, and his dead brain will continue to explode.

"Rub! Who wants you to care! ”

"If it weren't for the senior, you took the 9150 away, I wouldn't have left you alone!" Lan Zeguang gathered the hair on his ears, and then found some clues among the nine program alarms.

In the world of programmers, different variable types can cause conflicts with numbers. While there are some numbers that can be cast, there may be some paranormal situations. For example, in some compilers, u8 and char are the same variable, but sometimes, they are a little different.

Senior Dong Chen's 9 warnings appear here, fusing the number JÙ's IIC bus pointer with two similar, but different variables. Lan Zeguang pulled out the keyboard and changed him out.

"What are you doing, what are you doing!" Seeing that Lan Zeguang was about to move again, Senior Dong Chen, who deserved Mi's girlfriend, was anxious again.

"I'll help you change u8 to char so that you don't thank me without warning?" After the change, compilation, there are still warnings, but the content of these warnings is that the defined variable is not being used, which is irrelevant. Lan Zeguang recompiles and loads the microcontroller again, but there is still no number of jù outputs on the debugging software.

"What the hell are you doing! The more you change, the more messy it gets! it! You're a little funnier! Senior Dong Chen was standing behind Lan Zeguang, looking at it and about to kill. The classmate next to him grabbed him with a dry smile and said, "Dong Chen, you just let the senior sister, what kind of anger are you making, you have something to say!" ”

"Let Mao!" This guy is still going berserk.

And at this time, the little friend pulled him out.

"Hey! Why are you anxious about a girl? I still wish someone would help me change the program! I'm happy to change it in a mess, is there something wrong with your brain? ”

"You're the problem!" Senior Dong Chen glared at his little friend fiercely.

"What, I'm wondering, are you wise and foolish to attract the attention of other students? No matter what, people are also laughing at the school flower level, although they have a boyfriend......" As he spoke, he looked at Lucifer, who was sitting next to Lan Zeguang's seat and reading a book with Erlang's legs crossed.

Alas, the combination of a cute girl and a cute boy is so dazzling. The world of pseudo-lilies is right in front of you, and for an otaku, it's simply a good opportunity to give your soul to Lucifer.

However, Dong Chen is not wise and stupid at all, he is purely a fool who deserves to have no girlfriend. He looked at his little friend with a strange look and yelled: "Your brain must be abnormal, why is your thinking so jumpy?" How could I possibly be interested in that kind of girl? ”

“…… You deserve to have no girlfriend! ”

"You've stressed it so many times, didn't you say yes, bastard!"

……

I have to say that after the senior's friends pulled him out, Lan Zeguang was able to calm down and look at his program. Because it was transplanted, according to the experience of the "old professor" in his head, Lan Zeguang quickly found a possible location. That's where the ported program and the native program intersect, which is the IIC bus control program written by yourself, and the IIC bus of the ported program.

Dong Chen annotated the program of the transplanted part, but through the comparison, Lan Zeguang could also see it.

-- Here's the problem!

The ported program has a problem with the settings of the IIC bus initialization.

Probably because it is rare to add a bunch of IC chips to the IC bus on weekdays, the initialization of the IC bus of Dong Chen's program is "single mount" by default, that is, such an IIC program can skip the step of chip address response. Lan Zeguang found the comment in the macro definition part and quickly changed it.

Compiled, compiled and completed. 0error,0warning,and then click the loading button,The program is downloaded to the microcontroller。

And at this time, Dong Chen broke free from the entanglement of his friends, walked back from the real room in a hurry, and then saw the scene in front of him.

Lan Zeguang fiddled with the gyroscope chip, and then the screen showed the number of gestures directly fed back by the DMP controller, and some of them were very harmonious.

"......" Dong Chen was dumbfounded.

Of course, he will not be unconvinced. In addition to not having a girlfriend, programmers have another trait - that is, they are fanatical about technology.

"How did you do that?" This senior swept away his previous irritability at once, and suddenly came to Lan Zeguang in a frenzy. Then, it's a topic that the programmer ape can only see. Ten minutes later, Lan Zeguang clarified the problem, and then took out the USB flash drive from his bag and said.

"Senior, I can take the program!"

"Oh......" Dong Chen still had an endless aftertaste in Lan Zeguang's clear explanation. Then when he heard Lan Zeguang change the topic, he was suddenly startled.

"I ...... I'll go! How could you possibly find this bug! (To be continued......)