I have a tendency to do things the hard way. Especially once I’ve gotten it in my head to get things done that way. I have thusfar learned to program for the MSP430 series by poking bits on hardware registers. The big stumbling block is that the names of these registers and the symbols for some of the common values change between types of chips within the series. Every so often I go looking for information about the proper names for the specific chip I’m using and run into a mess of examples using Driverlib. I’ve not mentioned this collection of software before. In short, Driverlib is a conspiracy by Texas Instruments to permanantly obfuscate the function of its hardware behind uninformative function calls that don’t give any indicator as to what’s going on under the hood. Or, as they put it “Enabling embedded programming using API-based procedures instead of register modification”.
Aside from being too friendly and making me feel as if they are actively trying to prevent me from learning what’s going in, the function calls are way too verbose.
Simple example. I want to set Pin 1.0 to output a high signal. By poking registers I need these two lines:
P1DIR &= ~BIT0; P1OUT |= BIT0;
Using Driverlib, it is also two lines:
GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0); GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
But it is a lot of extra typing and a lot of words that don’t say anything. Sure, somebody walking in with no understanding of the hardware can look at them and be lost by the first while getting what the second does, but this isn’t code anyone else is going to maintain. I’ve gotten comfortable poking bits on registers, and I’d really rather not use any Driverlib functions.
But…
I2C is complicated and trying to dissect and translate register poking code to my version of the chip runs afoul of the name changes. I can’t find the registers I need to poke, or the values I need to set. I have one more option – I ordered my second textbook of this endeavor which is based on the same chip I’m using exactly. If I can’t work it out with that, I may have to rip chunks out of the Driverlib code to get something running. (I really don’t want to import the whole bloated library).
Several Days Later…
I was elated the moment the textbook arrived because the promised pages of Chapter 14 did indeed give me all the information I was lacking. I could reference what those registers were called, what the special values were named, and even had explainations beyond what I could augur from the header files and random almost-related internet examples.
Excitedly, I went about composing some I2C code applicable to my situation. I wired up the same simple string of LEDs and jumpered the output of the RTC module’s square wave pin to the input pin I’d used for the button previously. I loaded my new coad and…
Nothing happened.
There was a lot of nothing as I stared at code. There’s no way to make this step exciting.
In frustration, I dragged the whole thing over to my oscilliscope to see if the RTC was outputting a square wave. I am still not very good with the oscilliscope, but I did manage to find this signal.
While the fuzz at the flat section initially caught my attention, the real information was that this was still running at 32KHz. So I was not updating the RTC to the 1Hz signal I wanted. I went back to staring at my code.
I eventually found my off by one error.
For those of you who don’t know, an off by one error is a common problem in programming. The two common types are when you start counting from one when the computer starts at zero, or when your comparator stops one short of where the loop is meant to. Mine was in the loop that went through the array holding the data to be sent to the RTC module. As such, it was never actually setting the register to anything.
With the code fixed, I got the LED to march along at the command of the RTC module.
Now, all the code staring was over, I had to address the hardware again. After reviewing the PCB design I’d had done to connect the pluggable MSP to the clock, I found a number of mistakes. Some fiaxble in code (I’d connected to the wrong pins, but they were still in the same block of I/O pins). Others required hardware fixes. In the Datasheet for my MSP430FR2355 the pinout diagram for the package I am using there is a misprint. The reset pin is not marked as active low. Elsewhere, it is properly marked as such. Stupidly, I’d looked at the pinout and on the datasheet and tied reset to ground. By a stroke of luck, GT drew my attention to those pins and I realized my error. So I broke the trace. I could have bodged directly to power, but best practice is to use a pull up resistor instead.
The other bodge I needed to do was connect the square wave to an input pin. As the pin I had used for the testing wasn’t used in the existing design, I ran the bodge from the square wave pin to that input. Together, the updates look like:
I merged my code from the I2C work and the original clock, adjusted for the hardware mistakes, and jumpered my launchpad adapter into the daughterboard adapter, and plugged that into the clock. This debugging rig ended up consisted of nine jumper wires, six circuit boards, three MSP430s, and one pair of crossed fingers.
However, this monstrosity worked. With someone else managing the temperature compensation for the clock crystal, my hobbyist code was able to keep reliable time. I ran it overnight and it kept good time.
Finally, I had my starter objective complete. Now I can move on to the real project.
But there have been developments unrelated to the project.
The delays have overrun the backlog of articles, so I started to churn out filler to try to keep content rolling while I worked the problems. This resulted in a notable quality drop. I have been asked if I can wrap up or go on hiatus. Since the real project isn’t done, I don’t want to wrap up, but I also don’t want to keep throwing filler articles at you lot. You deserve better for your $0.00.
So, here’s what I’m going to do. I’m going to reserve new article releases for major milestones, and I’m going to minimize attention paid to topics already covered in this series. I will look for ways to show other aspects and share what I’ve learned that doesn’t sound like a rerun.
Next up – Thermometers. ETA – I have no clue.
For now, I leave you with an image of the clock removed from the debug harness.
When do you add the date function?
(-.-)
😉
swipe_left();
This is an impressive process.
Since the real project isn’t done
I’d say the process is the project.
When I built my 1911, I did it for the sake of doing it. If I had just wanted something to shoot, I could have bought one over the counter, for less than I ended up spending.
Exactly.
The goal of self-edification stretches past the individual projects.
A project has a concrete completion criteria.
You’re the only one I know excited to get a textbook.
The finished project is beautiful. Nice and neat and well organized. Thanks for sharing!
It’s a carefully posed picture. It looks worse from other angles.
I made a few circuit boards in college. That was under supervision and with formal instruction. None of them looked nearly as good as yours. The “bad side” can’t be that bad.
I was thinking more of the fact that that final image is four boards stacked atop each other. I did design three of them, but I can’t make a case for that stack the way it stands. I’d have to redesign it to move forward along that branch.
To be fair I’ve had that happen with some of my Japanese language textbooks.
Speaking of hobbies and content, I have been working on some of the pinup girl paintings we talked about last week. For the current batch I’m taking photos of the process and the plan is to write a post about it.
Waymo cars honk at each other throughout the night, disturbing SF neighbors
https://www.youtube.com/watch?v=Xvs0K1LG1ac
They’re plotting.
I don’t know if it was “Waymo” or “SF” that made me laugh more.
Those cars look like something out of Demolition Man.
Beth Mole at Ars never disappoints. “Be sure to drink your Ovaltine”
This year’s summer COVID wave is big; FDA may green-light COVID shots early
https://arstechnica.com/science/2024/08/amid-summer-covid-surge-fda-reportedly-poised-to-approve-updated-shots/
Technically it should be Ellipsetine, not Ovaltine.
Murmuration. Birds, fish, sheep, buffalo, people. I personally could never get the hang of it.
https://infeed.in/wp-content/uploads/2019/06/august-landmesser-no-salute.jpg
I am not familiar with that website, so I thought the comments would be sane.
Spoiler alert: THEY ARE NOT
One example:
Ars is full of Top. Men. aka technocrats.
They have very good technical coverage of computers and their space journalism is quite good. OTH, when they move into anything public policy related to health, tech and AI and the like they are absolute statists.
You should have learned by now. The comments in all but a few places or dens of idiots, trolls, and progressives.
I know, right?
RIP “Matoko Kusanagi”
One of my favorite Japanese voice actresses just passed away. She had a wonderful rich voice. I had no idea she was ill as she was still working in series that ran this year.
Atsuko Tanaka, the Voice of Ghost in the Shell‘s Major, Has Died
https://gizmodo.com/atsuko-tanaka-rip-ghost-in-the-shell-frieren-bayonetta-nier-naruto-2000488927
A minor oversight
BMW on Tuesday said it is recalling 720,796 vehicles in North America because they are equipped with an electric water pump that may short circuit as a result of faulty installation, posing a fire hazard.
According to recall documents posted by the National Highway Traffic Safety Administration, “An improperly sealed electrical connector on the water pump may be exposed to water and short circuit.”
More specifically, “blowby-liquid from the positive crankcase ventilation system may collect on the intake air hose,” and eventually “drip onto the plug connector,” potentially seeping in, causing an electrical shortage.
“This could increase the risk of a thermal event and, in rare cases, a fire,” the recall states.
It never did that in the lab.
BMW Engineer 1 – what we really need is an electric water pump. Yeah that makes sense significantly more complex and shorter lifespan, but it should outlast the warranty and get us some horsepower and fuel economy.
BMW Engineer 2 – Great point! You know what we can also make the impeller out of plastic. It will be cheaper and still fail according to my models outside the warranty period.
BMW Accounting – WIN!
In the old days, it was explained to me that a warranty covers infant mortality — undetected defects in material or craftsmanship. It is not supposed to define the life expectancy of a part.
My assumption was In the old days finite element analysis failure analysis was expensive and couldn’t be run on everything in a vehicle.
Blah, don’t talk to me about plastic impellers. I am tossing a fairly new dishwasher for just that.
If PCV venting would collect on a hose and drip into an unsealed connector, what about ordinary condensation in high humidity or road spray?
Apparently, all the protesters left Chicago. There’s not a single article on Google News talking about protests at the DNC.
Busy getting abortions and sterilizations today.
I can’t believe the sexism of PP offering free vasectomies but NOT free tubal ligations! Someone should sue them.
https://www.cbsnews.com/chicago/news/protesters-breach-security-fence-democratic-national-convention/
Buried in there, the US Capitol Police are providing security a party’s political convention. The same jokers that couldn’t “protect” the actual Capitol.
POTUS and VPOTUS are there.
Oh well.
Unlimited checkbooks.
The Secret Service can protect them just like they protect Trump.
I don’t understand most of this, but it is interesting to see your troubleshooting process.
I am trying to figure out if I can install a new double din Pioneer stereo in my truck to replace my clarion and the wiring is intimidating.
You do know about https://www.the12volt.com, right?
No, I did not, but it looks helpful.
Thanks
I’m taking the FJ in for a new head unit. Also, because its a 2008, and (a) FJ’s have possibly the worst rear visibility of any vehicle ever made and (b) the 2008’s don’t even have the rudimentary backup camera of later models, a backup camera.
I am taking it in for a professional install. As usual, five minutes worth of YouTube how-to video on this project sealed that deal.
That’s what I’m leaning towards.
I would like to do it myself, but don’t want to ruin the $450 Pioneer.
Ron – what I dislike is the mechanical ripping the interior out to fish wires.
The actual wiring on an aftermarket head unit is really not that awful if you think about it logically. 4 speakers time 2 wires = 8 wires. Switched 12V. Constant 12V. Antenna. GPS antenna (maybe) and Camera. Maybe some aux RCA jacks and a few other bits like a signal for an external amplifier.
Part of the thing that looks so daunting is the 50% of the bundle is speaker output.
Back in June I got a Durolane injection in my right knee. Durolane is a synthetic form of hyaluronic acid (HA), a natural substance that lubricates joints and helps cartilage move smoothly. I don’t have much meniscus left in my right knee along with having bone spurs and osteoarthritis. The Durolane gel combined with a cortisone shot makes my knee feel as good as new for 6 – 7 months. Anyway I was reviewing the statement from my insurance company for the Durolane shot – they were billed $3266.00 and paid the entire amount. Curious, I did a search for Durolane and was able to find 60mg/3mls syringes for $250.00 online. When I search for the cost of a Durolane injection Google’s AI returns: “The cost of a Durolane injection can range from $372 to $2,750, depending on whether you have insurance.” Curious why my insurance was billed $3600 for a dose of Durolane that can be obtained for under $300. Something appears fishy……
“Something appears fishy……”
Is it your avatar/name combo?
It’s a medical expense, of course it doesn’t make sense.
Another interesting thing on my insurance statement – each visit the doctor’s office bills my insurance $161 for the injection (Medical CPT code = 20610). My insurance will only approve and pay $37.00. I do not get billed for the difference. Strange.
Correct. Usually part of their billing contract is that they’ll accept the lower amount and not bill you for the difference. There’s reasons for maintaining high list prices.
Remember, your insurance is paying for every junkie who overdoses to get treatment.
“I ran it overnight and it kept good time.”
🎉 🥳 👏
Took me long enough.
Good time(s)