Example Of Non Irq Function Fills Buffers and IRQ Function Empties Buffers This implemenation is based on the function sending the data being an irq which sends bits of the data irq calls and the function filling the data buffers being non irq and ensuring the operation is irq safe. #define FILE_DATA_NUM_OF_BUFFERS 4 #define FILE_DATA_BUFFER_LENGTH 512 […]
All posts by
if
If (variable) Anything that’s not a 0 is a true value in if If with load of a return value into a variable Ensure you enclose the assignment in brackets or it won’t work correctly
Variables – stdint.h types
In C99 the available basic integer types (the ones without _t) were deemed insufficient, because their actual sizes may vary across different systems. The C99 standard includes definitions of several new integer types to enhance the portability of programs. The new types are especially useful in embedded environments. All of the new types are suffixed […]
Variables
Volatile – Variables Which Can Be Altered In Interrupts Ensure these variables are declared with the 'volatile' keyword so the compiler knows the variable can be changed in an interrupt. This can be a classic cause of very strange bugs where you can't understand why your release code seems to be getting locked up, say, on a while loop […]
C Versions
ANSI C89 ISO C90 Very close to ANSI C89. Describes exactly the same language. Under ISO rules, they added some front matter and renumbered the sections. ANSI officially adopted the ISO C90 standard after it was issued. ANSI C89 became obsolete at that point C94 Not a full standard but a Normative Addendum. ISO C99 ISO 9899:1999. Free download. […]
C++ Versions
C++98 (ISO/IEC 14882:1998) is the first edition C++03 (ISO/IEC 14882:2003) is the second edition and often considered a bugfix. However it has many changes. C++11 (C++ 2011 Standard) is the third edition. C++14
Time Since Event From A Master Timer
An Example Using A Master Roll Over Timer To Get Time Since Last Event //—– DO IN 1mS HEARTBEAT TIMER —– main_1ms_clock_timer_irq++; //—– USING THE TIMER —– unsigned long main_1ms_clock_timer_irq; unsigned long main_1ms_clock_timer; unsigned long process_last_time; unsigned long process_1ms_time_since_last; //Create a local copy of the timer (which won't change in the interrupt when being used […]
State Machine
A Mode State Machine
Arrays
Multidimensional Arrays Array length See sizeof()
C vs C++ General
Return Type In C, any function with no return type specified is assumed to have a return type of int. In C++, no such assumption is made, and it's a compile-time error to not specify the return value of a function.