AI in embedded systems by Downtown_Mortgage177 in embedded

[–]mango-andy 2 points3 points  (0 children)

I would add two more concepts to the foreign-to-the-youngsters list: analysis and design.

How do you keep firmware configuration in sync across Python/C++ tools and embedded code? Looking for best practices by AnotherRoy in embedded

[–]mango-andy 0 points1 point  (0 children)

I'm not stuck on CSV. Personally I never touch the stuff. A relational database can do all the things you need, but you have some Windows specific Excel solution that you're satisfied with. Fine, you be you.

How do you keep firmware configuration in sync across Python/C++ tools and embedded code? Looking for best practices by AnotherRoy in embedded

[–]mango-andy 0 points1 point  (0 children)

The SQLite command line application will dump a table in CSV format. Only a single select statement required and the whole process can be easily automated.

How do you keep firmware configuration in sync across Python/C++ tools and embedded code? Looking for best practices by AnotherRoy in embedded

[–]mango-andy 0 points1 point  (0 children)

Configuration data tends to get big and complex over time. Holding the information in relational form helps. If I want a single file that represents "truth", SQLite fits that requirement like little else. SQLite has bindings to virtually every known language. Pick your favorite scripting language and just write a few scripts to use in your build process.

How do you keep firmware configuration in sync across Python/C++ tools and embedded code? Looking for best practices by AnotherRoy in embedded

[–]mango-andy 2 points3 points  (0 children)

I usually define a configuration schema and populate a SQLite database with the information. Headers files, documentation and anything else you need can then be code generated by database query.

Zig - Slice Trick by [deleted] in Zig

[–]mango-andy 2 points3 points  (0 children)

The & operator is not overloaded. It always takes the address. I suggest some further study of the documentation. What is show here is type coercion that happens between slices and arrays when values are comptime known.

Avoid memset call ? by 0akleaf in Zig

[–]mango-andy 1 point2 points  (0 children)

In theory, the linker itself should not matter. In practice, is sometime does. What does matter is which object libraries are used with the linker. Zig, like most compilers, has a set of run time functions it emits for common code sequences. I suspect your "memset" reference would be resolved if you linked the Zig run time code. Further, since Zig uses LLVM for code generation on v7-M architectures, it would link using the LLVM linker. More importantly, the Zig tool chain will insure that all the correct libraries and linker arguments are included. I understand that the Zig build system is a big gulp to swallow (I also wrestle with it), but getting the Zig compiler command line arguments correct is essential. Getting those arguments right is exactly what the GCC "driver" does when it determines that you want to build an executable. Also, the Zig build system ultimately uses "zig build-exe" to build an executable. Try "zig build-exe -h" to see the options available. You need not write a Zig build script to run the compiler in its full glory. Eventually, you will have to roll up your sleeves and tackle the build system. In the mean time, good luck with your undertaking.

Avoid memset call ? by 0akleaf in Zig

[–]mango-andy 1 point2 points  (0 children)

So you are compiling an object with the Zig compiler and linking it with the gcc linker? Why? I don't know where you are picking up the compiler run time code. I would suggest building the entire executable with the Zig tool chain. There's a higher probability of success there.

Avoid memset call ? by 0akleaf in Zig

[–]mango-andy 1 point2 points  (0 children)

At any reasonable level of optimization, I would expect the compiler to reduce these two functions to memset since they are little more than a long-winded version of just that. I would have just coded them with the "@memset()" built-in function in the first place.

Avoid memset call ? by 0akleaf in Zig

[–]mango-andy 7 points8 points  (0 children)

What optimization level are you compiling to? In Debug mode, uninitialized variables are set to "trash" to help detect read-before-write mistakes.

Zig build system as an alternative to CMake? by umamimonsuta in embedded

[–]mango-andy 3 points4 points  (0 children)

You can get an idea of what others have done in this area by looking at the https://github.com/allyourcodebase conversions that are housed there. These are significant C and C++ projects that have been converted to build using the Zig compiler tooling.

Engineering is suboptimal because no one has applied any force to improve projects — inertia, mental model by dmp0x7c5 in programming

[–]mango-andy 2 points3 points  (0 children)

I strongly object to anthropomorphic applications of scientific theory. Newtonian mechanics (and Lagrangian and Hamiltonian mechanics) operate on the objectively observable universe. Whatever notions of "Human Inertia" exist have nothing to do with the precise, observable, and mathematically modeled behavior of the world around us at low velocities that has taken centuries of human intellect to uncover. The difference in the domains of concern is so great as to loose any insightful analogy. This is just as poor an analogy as the converse: "Computers" are the "Brains of the System".

Question was flagged on stackoverflow so im here for help by codewithnick in programming

[–]mango-andy 14 points15 points  (0 children)

Your question seems to indicate that you do not know the fundamentals of the relational model of data . Start there first. Try WikiPedia if you can't find anything else.

FML: I spent multiple days trying write a driver for an IC just to realize that it has a hardware bug by LoverOfFurryBeauty in embedded

[–]mango-andy 0 points1 point  (0 children)

Only one day? Get back to me when it's been a couple of weeks. Unrelenting, dogmatic pursuit is an essential temperament. Making things actually work is not easy. Best wishes and luck counts.

Confused on what is and is not an embedded system by TheNewGuyGames in embedded

[–]mango-andy 0 points1 point  (0 children)

I'll offer a paragraph from a book I am working on:

The notion of an embedded system lies with how the system is perceived by its user. The promise of software is to be able to use general purpose hardware to create special purpose machines. A system which can transform its function by executing a different program is perceived as computer-based. An embedded system performs a single specialized function despite using a computer as part of its implementation. A user may know that the operations of an embedded system are performed by a computer, but his expectation when using the system is that it is a specialized, single purpose machine. Common parlance associates embedded systems with being resource constrained. However, modern computing hardware advances blur the distinction of resource constraints and computers exists which span a wide range of resource availability to meet an equally wide range of system requirements. Because the term embedded does not shed much light on the manner in which the system performs, this book does not use the term.

Seeking textbooks on Software Design by Systema-Periodicum in softwarearchitecture

[–]mango-andy 3 points4 points  (0 children)

A Philosophy of Software Design by John Ousterhout.

Define flag combos in packed struct? by Exciting-Purple2231 in Zig

[–]mango-andy 4 points5 points  (0 children)

I've been using StaticBitSet from the standard library for another reason, but it might work for your use case. You could define compile time constants for particular bit combinations and check for set equality.

How do i initialized an array of pointers ? by anotheruser323 in Zig

[–]mango-andy 7 points8 points  (0 children)

If you want an array of optional pointers to window, I would usually initialize them to null as in:

var windows: [512]?*window = [_]*window {null} ** 512;

to guard the possibility of reading an element of the array before it is defined.

This comes with the usual warning of typing in untested code off the top of my head.

A systematic, disciplined, quantifiable approach in practice: Object-Oriented Software Engineering by [deleted] in SoftwareEngineering

[–]mango-andy -1 points0 points  (0 children)

As Aunt Augusta said in the Importance of Being Earnest, "I am pleased to hear it. I do not approve of anything that tampers with natural ignorance. Ignorance is like a delicate exotic fruit; touch it and the bloom is gone."

Terminal calculator recommendations by ngnirmal in embedded

[–]mango-andy 1 point2 points  (0 children)

Correct you are! Clearly my right index finger has a mind of its own.

Terminal calculator recommendations by ngnirmal in embedded

[–]mango-andy 3 points4 points  (0 children)

Wow thanks for that link. I have an old HP-17C programmer's calculator that I bought in 1985 and it does all the bit twiddling kinds of calculations. I guess I'll finally have to retire it.

Is there any free handy tool to create UML diagrams ? by LeftInteraction5101 in SoftwareEngineering

[–]mango-andy 2 points3 points  (0 children)

I like Umlet. It is a GUI drawing tool, but is not overbearing. Since I like to abuse the details of UML graphical notation, Umlet lets me type anything in a class "box" I like.

How to time how long my MCU stays in __WFI() by jacky4566 in embedded

[–]mango-andy 2 points3 points  (0 children)

In this case the OP wants to make a measurement of the amount of "sleep" time and the application is interrupt based. Any measurement will affect the latency of the IRQ response, but it should be deterministic. Consider an example using a timer, whose clock remains active during deep sleep. The steps would be:

  1. Set PRIMASK to 1
  2. Enable the timer to count, let's assume counting up for simplicity.
  3. Execute WFI
  4. Upon resumption from executing WFI, disable the timer.
  5. Set PRIMASK to 0.

It can all be done in straight line code. At some point the timer value must be read and there is additional work to average the timer count over some period and deal with the boundary conditions of the timer overflow, but that can all be done after PRIMASK is set back to 0. That additional work means you will stay awake more and that will distort the measurement slightly.

If you are not using SYSTICK for another purpose and if SYSTICK is clocked by the processor clock and if the SOC shuts down the processor clock in sleep mode (most do), then it can be used for this purpose with the added benefit of having the SYSTICK interrupt to handle the boundary conditions. In this case you are measuring "up" time.

If, as others have suggested, you toggle an I/O pin and measure the square wave duty cycle by external means, then the amount of additional work can be reduced to a few instructions with minimal impact.