meaning of &variable (passed to function)

func being some arbitrary user defined function It couldn’t be “arbitrary” – it must take a pointer to int or a void* in order for the call to be legal. This ampersand is the “take address” operator. It passes func the address of a, so that the func could, for example, modify it: If your … Read more

How do you implement a class in C?

That depends on the exact “object-oriented” feature-set you want to have. If you need stuff like overloading and/or virtual methods, you probably need to include function pointers in structures: This would let you implement a class, by “inheriting” the base class, and implementing a suitable function: This of course requires you to also implement a … Read more

What are .axf files?

The AXF file is an object file format generated by ARM’s RealView compiler (also part of Keil’s ARM-MDK) and contains both object code and debug information. In the debugger, while just the object code is loaded on the target itself, both the code and the debug information are loaded in the development host’s memory. When … Read more

Using floats with sprintf() in embedded C

Since you’re on an embedded platform, it’s quite possible that you don’t have the full range of capabilities from the printf()-style functions. Assuming you have floats at all (still not necessarily a given for embedded stuff), you can emulate it with something like: You’ll need to restrict how many characters come after the decimal based … Read more

How to program hardware?

Probably you are looking for a programmable microcontroller. If you have experience in C/C++/Java, checkout Arduino. Its chip is programmed using a C like language. This “How tos” page might help you get started. There are also some good books that will help you move forward: Programming Interactivity. Making Things Move DIY Mechanisms for Inventors, Hobbyists, and … Read more

ARM Assembler – How do I use CMP, BLT and BGT?

You cannot do a conditional branch without first setting the condition register somehow. This can be done with cmp or by adding s to most instructions. Check out the ARM assembly documentation for details. Quick example: Branch if r0 greater than 5: Compare r6 with r4 , put difference into r7, branch if r7 < 0: