General Programming

Contents

  1. Child Pages

Child Pages

Automated Code Analysis
ContentsOverviewStatic vs. DynamicCode Analysis Program ReviewClangStatic AnalyserCppcheckFlawfinderFrama-CPC LintOverview Automated code analysis is when code reviews other code. It can also be called static analysis, as most programs which do this check the source code without actually running the program (which is where the term static comes from). Static vs. Dynamic Static analysis involves checking a programs source … Continue reading Automated Code Analysis
Bootloaders
ContentsOverviewChild PagesGolden ImageOverview Bootloaders are typically loaded by the devices ROM or BIOS. Child Pages Golden Image A golden image is a firmware application with minimal support for firmware updating. If updating over-the-air (OTA), than this image must include basic wireless comms support. It is usually stored either in external flash or in a protected area … Continue reading Bootloaders
Character-Seperated Value (CSV) Files
ContentsTerminologyGeneral RulesStandardsTerminology A CSV file is made up of many records, where a record is a single entire line in the file. Each new line is signified with the record delimiter (typically a carriage return and line feed character, CRLF or \r\n). A record is made up of many fields, each which a seperated by … Continue reading Character-Seperated Value (CSV) Files
Checksums
ContentsFletcher’s ChecksumFletcher’s Checksum Transmitter Methodology Calculate checksum on raw  data Using the raw data and the newly found checksum, calculate the checkbytes Add the checkbytes to the end of the data packet Transmit data Receiver Methodology Receive data packet Calculate checksum (including the checkbytes) Make sure checksum equals 0, if so, data passed the checksum … Continue reading Checksums
Code Libraries
ContentsC Code LibrariesC-FreeRTOS-LightsC-FreeRTOS-PerformanceMetricsC-FreeRTOS-UARTC-PSoC-FreeRTOS-CliC++ Code LibrariesCpp-ClarkTransformationCpp-ClideCpp-ParkTransformationCpp-FixedPointCP3id (CppPID)Cpp-LinInterpSauronFiFoFumC# Code LibrariesCs-ClideVisual Basic ScriptsAltium-ScriptsMixed LanguageLocalExtremaBelow are CladLabs open-source (GPLv3) code libraries. All are Git repositories that are hosted on my GitHub account. Feel free to clone and submit issues/pull requests! Most of these libraries are designed for embedded applications, although nothing is stopping you using them on more powerful … Continue reading Code Libraries
Code Licenses
ContentsOverviewThe BSD 3-Clause LicenseGPLGPLv3Overview If you have been working with code for a while, you’ve probably come across licensing, and terms like “Free as in Speech”, or “Free as in Beer”. What does it all mean? The BSD 3-Clause License URL: http://opensource.org/licenses/BSD-3-Clause GPL URL: http://www.gnu.org/licenses/gpl.html The GNU General Public License (or GPL) is a license maintained by … Continue reading Code Licenses
Command-line Interfaces
ContentsOverviewCommand Description (Help) SyntaxOverview A command-line interface is a way of interacting (sending instructions, receiving info) with programs on a computer. NOTE: For a C++ command-line interpreter, that can run on both embedded and P.C. architectures, see clide-cpp on Github. See C->Processing Command-Line Input for how to write C code for dealing with command-line arguments … Continue reading Command-line Interfaces
Continuous Integration
ContentsTravis CIThe .yml FileTravis CI Travis CI is a free (for public repositories), online, hosted continuous integration service. Website: https://travis-ci.org/ Travis CI is closely tied in with GitHub, allowing Travis CI to automatically manage the CI process for projects that are hosted on GitHub. All you have to do is add a yml file (see below), … Continue reading Continuous Integration
Control Methodology
ContentsOverviewState Machines (single process)A Big switch() StatementReal Time Operating Systems (RTOS, multiple process)ExamplesFrameworksOther External LinksOverview You may think that after writing the state machine for flashing a few LEDs and a buzzer that control metholody is a simple task that doesn’t require further discussion. However, add in a multi-threaded operating system, asynchronous events, more objects … Continue reading Control Methodology
CRCs (Cyclic Redundancy Checks)
ContentsOverviewGenerator PolynomialStart ValueMSB-first vs. LSB-firstProperties Of CRCsCRC CalculatorsSome Common CRC AlgorithmsCRC-8-ATMCRC-16 (CCITT-FALSE)External Resources Overview “Everything you wanted to know about CRC algorithms, but were afraid to ask for fear that errors in your understanding might be detected.” – Ross N. Williams.   Generator Polynomial The hexadecimal representation of the polynomial is what you end up exclusively-ORing the … Continue reading CRCs (Cyclic Redundancy Checks)
Debugging On An Embedded System
The differences between computer/microcontroller debugging, code examples for powerful printf()-style microcontroller debugging and more info on debugging in an embedded system.
Doxygen
Overview, quick reference (cheat sheet), file headers, function documentation, grouping, the main page, Doxywizard, code examples and more info on using Doxygen, an in-code method for generating software/firmware documentation.
Eclipse
ContentsCheat SheetCheat Sheet Ctrl + Tab Switch between source and header files. F3 Switch between declaration and definition (for functions/methods/variables e.t.c). Like this:Like Loading...
ELF Files
ContentsWhat Is The Difference Between BIN and ELF Files?Programs That Operate On ELF FilesELF Code LibrariesELFIOELF is an initialism for executable and linkable format. ELF files are binary object files. There are three different types of object files that an ELF could be: Type Of Object File Description Relocatable File A relocatable object file holds … Continue reading ELF Files
Encryption
ContentsOverviewHash FunctionsTypes Of AttacksBrute-Force AttackSide-Channel AttacksMan-In-The-Middle AttacksTEMPESTTraffic AnalysisOverview There are two basic types of encryption used widely in computer science, symmetric and asymmetric algorithms. Symmetric algorithms use two identical or very similar keys to both encrypt and decrypt the information. Their main problem is that the sender and receiver need to share these keys securely … Continue reading Encryption
File Systems
ContentsOpen-Source File SystemsFatFsOpen-Source File Systems FatFs URL: http://elm-chan.org/fsw/ff/00index_e.html A generic file-system module designed for embedded systems which supports a Windows-compatible FAT file structure. It is written in compliance with ANSI C and is separated from the disk I/O layer, therefore is independent of hardware. Supports RTOS (i.e. supports threading/tasks). Sample projects exists (with the driver layer … Continue reading File Systems
Fixed Point Mathematics
ContentsNotationThe Range Of Fixed-Point NumbersThe Precision Of Fixed-Point NumbersConverting To Fixed-PointAdding/Subtracting Fixed-Point NumbersMultiplying Fixed-Point NumbersEmbedded C++ Fixed-Point LibraryExternal ResourcesFixed-point mathematics is a method for representing numbers on a binary computer architecture. It allows the storage numbers with decimal points, similar to the float and double, but with the benefit of requiring less computation time. The … Continue reading Fixed Point Mathematics
Makefiles
ContentsOverviewThe Simplest Possible MakefileAdding VariablesWildcardsAutomatic VariablesIncluding One Makefile In AnotherCalling One Makefile From AnotherDebuggingMore ReadingOverview Makefiles are a way of making a “one touch” build solution for source code. They are a type of file used by the GNU command make. They take multiple file inputs, do some part or all of the code build … Continue reading Makefiles
Memory
ContentsWhat To Do With Unused MemoryWhat To Do With Unused Memory When writing code for microcontrollers, it can be advantageous to fill unused memory with particular code. For example, you may wish to fill unused flash memory with “jump to safe place” instructions, which will redirect the program if the CPU program counter goes to … Continue reading Memory
Microcontroller IDE Comparison
ContentsOverviewAVR StudioEclipseKeil uVisionOverview Below is a comparison of some of the more popular microcontroller IDEs (integrated development environments). The results from the 2012 embedded survey were interesting… AVR Studio Cost Free Supported Operating Systems Recent Windows Supported Architectures All 8-bit and 32-bit ATMEL micro-controllers… ATmega ARM AT91 Supported Languages C C++ Supported Compilers WinAVR Supported … Continue reading Microcontroller IDE Comparison
Naming Conventions
See the C Naming Conventions page. Like this:Like Loading...
NMR Quadrupolar Splitting Control Theory
ContentsGoverning EquationPerturb And ObserveSolid-State NMR Governing Equation $$ f_{split} = \lvert 3\cos^2 \theta – 1 \rvert $$ where: \( f_{split} \) = the normalised split frequency (between 0-2) \( \theta \) = the spin angle (between 0-90 degrees) This equation shows that a split frequency can potentially have two possible spin angles (when the split … Continue reading NMR Quadrupolar Splitting Control Theory
PID Control
ContentsOverviewDifferent Types Of PID ControlThe MathsTuning MethodsIntegral WindupFirmwave ModulesExternal LinksOverview PID control is a very common technique for controlling a system in which you have a desired set-point for the system to be in, and are able to control this with one variable. PID is an acronym for proportional-derivative-integral, and describes the three mathematical processes … Continue reading PID Control
protobuf
ContentsOverviewInstalling.proto FilesValid Scalar (Primitive) TypesReading From A ProtobufC++Writing To A ProtobufC++Serialization/DeserializationProtobuf And CMakeApplicationsOverview protobuf is an open-source, multi-language library from Google for serialising/deserialising data. It is designed as an efficient, language agnostic way of sending data over messaging protocols such as TCP/UDP, or UART/SPI/I2C e.t.c. Source code and downloads can be found at https://github.com/google/protobuf. Installing The installation … Continue reading protobuf
Signal Processing
ContentsFinite Impulse Response (FIR) FiltersInfinite Impulse Response (IIR) FiltersSource CodeFast Fourier Transforms (FFT)Source CodeLocal Maxima/Minima (aka Peak/Trough) DetectionIterating Over The DataSampling WindowLocal Extrema Code LibrariesConvolutionCorrelationDetecting Variable WraparoundsCurve FittingSplines The Math.Net project contains the “Neodym” library for signal processing in C#. The project can be downloaded, compiled in C# Express to produce a .dll, and then included as a resource … Continue reading Signal Processing
Time Measurement Systems
ContentsUTCUnix TimeYear 2038 BugLeap YearsWhat Are Leap Seconds?Trivial SecondsLeap SmearsOther Time SystemsIridiumUTC UTC (coordinated universal time) is a standardised measure of time that most people use in their day-to-day lives. Time zones around the world are expressed as an offset relative to UTC. UTC is not very programmer friendly. To calculate the interval between two UTC dates, … Continue reading Time Measurement Systems
Unit Testing
Information on the purpose of unit tests and the various unit test frameworks available.