How to run a C program with no OS on the Raspberry Pi?

Fully automated minimal bare metal blinker example Tested on Ubuntu 16.04 host, Raspberry Pi 2. https://github.com/dwelch67/raspberrypi is the most comprehensive example set I’ve seen to date (previously mentioned on this now deleted answer), but this is a minimal easy to setup hello world to get you started quickly. Usage: Insert SD card on host Make … Read more

How do you design a serial command protocol for an embedded system? [closed]

I have some preferences (and pet peeves) from writing software to control media and display devices using RS232. Depending on your hardware, some of these may not apply: I think it’s a good idea to make your protocol more friendly for automation. If you need an interactive interface (command line or other), build it separately … Read more

Embedded systems worst practices?

Uninitialized exception vectors (you know, for the ones that “will never be reached”) Say it with me: Global variables. Especially ones shared between ISRs and tasks (or foreground loops) without protection. Failure to use “volatile” where necessary. Having routines that DisableInterrupts() and then EnableInterrupts() paired up. Got that? Not RestoreInterrupts(), but ENABLE. Yeah, nesting. No … Read more

What is the difference between C and embedded C?

In the C standard, a standalone implementation doesn’t have to provide all of the library functions that a hosted implementation has to provide. The C standard doesn’t care about embedded, but vendors of embedded systems usually provide standalone implementations with whatever amount of libraries they’re willing to provide. C is a widely used general purpose … Read more

What is a jump table?

A jump table can be either an array of pointers to functions or an array of machine code jump instructions. If you have a relatively static set of functions (such as system calls or virtual functions for a class) then you can create this table once and call the functions using a simple index into … Read more

Optimizing for space instead of speed in C++

My experience from an extremely constrained embedded memory environment: Use fixed size buffers. Don’t use pointers or dynamic allocation because they have too much overhead. Use the smallest int data type that works. Don’t ever use recursion. Always use looping. Don’t pass lots of function parameters. Use globals instead. 🙂

Device misdetected as serial mouse

I just encountered this problem myself on Windows 7 Professional x64, and a solution that worked for me was to go into the registry and edit the following value: Location: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\sermouse Key: Start Value: 3 Change Value to 4 and it will stop this problem occurring. Here is a list of all valid Start values: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)