Cranes Varsity Blog

Like embedded hardware, embedded software architecture is highly flexible. Simple embedded software (such as electronic toys, calculators, and so on) may be only a few thousand lines of code and perform simple input and output functions. On the other hand, complex embedded systems (such as smart phones, robots, and so on) need more complex software architecture, similar to desktop computers and servers.

Complex embedded systems provide more powerful functions, need more convenient interfaces for users, and require the support of more powerful hardware. With the improvement of hardware integration and processing capabilities, the hardware bottleneck has gradually loosened and even broken, so embedded system software now tends to be fully functional and diversified.

An embedded software system is composed of four layers, from bottom to top:

  1. Hardware abstraction layer
  2. Operating system layer
  3. System service layer
  4. Application layer

Hardware Abstraction Layer

The hardware abstraction layer (HAL), as a part of the OS, is a software abstraction layer between the embedded system hardware and OS. It includes the boot loader, board support package (BSP), device drivers, and other components. Similar to the BIOS in PCs, the boot loader is a program that runs before the OS kernel executes. It completes the initialization of the hardware, establishes the image of memory space, and consequently enables the hardware and software environment to reach an appropriate state for the final scheduling of the system kernel.

Operating System Layer

An OS is a software system for uniformly managing hardware resources. It abstracts many hardware functions and provides them to applications in the form of services. Scheduling, files synchronization, and networking are the most common services provided by the OS. Operating systems are widely used in most desktop and embedded systems. In embedded systems, the OS has its own unique characteristics: stability, customization, modularity, and real-time processing.

The common embedded OS contains embedded Linux, Windows CE, VxWorks, MeeGo, Tizen, Android, Ubuntu, and some operating systems used in specific fields. Embedded Linux is a general Linux kernel tailored, customized, and modified for mobile and embedded products. In particular, VxWorks is used in the Mars probes by NASA.

System Service Layer

The system service layer is the service interface that the OS provides to the application. Using this interface, applications can access various services provided by the OS. To some extent, it plays the role of a link between the OS and applications. This layer generally includes the file system, graphical user interface (GUI), task manager, and so on. A GUI library provides the application with various GUI programming interfaces, which enables the application to interact with users through application windows, menus, dialog boxes, and other graphic forms instead of a command line.

Application Layer

The application, located at the top level of the software hierarchy, implements the system functionality and business logic. From a functional perspective, all levels of modules in the application aim to perform system functions. From a system perspective, each application is a separate OS process. Typically, applications run in the less-privileged processor mode and use the API system schedule provided by the OS to interact with the OS.


As soon as you open MATLAB you will get few windows on your screen, some of them are

  1. Command window
  2. Editor Window
  3. Command History
  4. Current folder
  5. Workspace
  6. Help window
  7. Figure Window

Having a brief idea about these windows will give a clear knowledge on how to interact with MATLAB, like, writing programs, designing GUIs, Modelling designs etc..,

Command window is the place where one or multiple commands can be executed one by one, and also the place where all the text and numerical related results will get displayed.

Editor window is used to write/edit scripts and save them.

Command History will store all executed commands from the time of your installation of MATLAB till you uninstall it.

Current folder will have all the files and folders in your current directory, and if you create any new file it will be saved in this folder only(unless mentioned).

Work space will have all the variables you are working now, work space will keep them temporarily maximum for one active session unless saved in .mat files.

Help window provides all the documentation required for each and every command and function available in MATLAB.

Graphical / Image related results will get displayed in a figure window.


Dynamic Memory Allocation is defined as a process where the size of a data structure can be modified during the run time.

There are certain predefined functions which can implement the above condition.There are 4 library functions provided by C all of which are defined under <stdlib.h> header file to facilitate dynamic memory allocation in C programming.

They are:

  1. malloc()
  2. calloc()
  3. free()
  4. realloc()


“malloc” or “memory allocation” method is used to allocate a single large block of memory baes on the specified size. The return type of malloc is of type void pointer which can be typecast-ed to any form.It initializes each block with a default value therefore some garbage value.


int *ptr = (cast-type*) malloc(byte-size)

For Example:  int *ptr = (int*) malloc(100 * sizeof(int));

Since the size of int is 4 bytes, this statement will allocate 400 bytes of memory. And, the pointer ptr holds the address of the first byte in the allocated memory.


“calloc” or “contiguous allocation” method is used to allocate specified number of blocks of memory baes on the specified type. It initializes each block with a default value ‘0’.


int *ptr = (cast-type*)calloc(n, element-size);

For Example: int *ptr = (float*) calloc(25, sizeof(float));

This statement allocates contiguous space in memory for 25 elements each with the size of float.


“free” method is used to de-allocate the memory or free the memory which was occupied by using the functions malloc() and calloc(),as they do not de-allocated on their own. Hence the free() method is used, whenever the dynamic memory allocation takes place. It helps to reduce wastage of memory by freeing it.




“realloc” or “re-allocation” method is used to dynamically modify the memory allocation of a previously allocated memory. The memory previously allocated with the help of malloc or calloc is insufficient, realloc can be used to dynamically re-allocate memory.


int*ptr = realloc(ptr, newSize);

where ptr is reallocated with new size 'newSize'

What is RFID?

Radio frequency identification, or RFID, is a generic term for technologies that use radio waves to automatically identify people or objects. There are several methods of identification, but the most common is to store a serial number that identifies a person or object, and perhaps other information, on a microchip that is attached to an antenna (the chip and the antenna together are called an RFID transponder or an RFID tag). The antenna enables the chip to transmit the identification information to a reader. The reader converts the radio waves reflected back from the RFID tag into digital information that can then be passed on to computers that can make use of it.

How does an RFID system work?

An RFID system consists of a tag, which is made up of a microchip with an antenna, and an interrogator or reader with an antenna. The reader sends out electromagnetic waves. The tag antenna is tuned to receive these waves. A passive RFID tag draws power from field created by the reader and uses it to power the microchip’s circuits. The chip then modulates the waves that the tag sends back to the reader and the reader converts the new waves into digital data.

Are there any health risks associated with RFID and radio waves?

RFID uses the low-end of the electromagnetic spectrum. The waves coming from readers are no more dangerous than the waves coming to your car radio.

Why is RFID better than using bar codes?

RFID is not necessarily "better" than bar codes. The two are different technologies and have different applications, which sometimes overlap. The big difference between the two is bar codes are line-of-sight technology. That is, a scanner has to "see" the bar code to read it, which means people usually have to orient the bar code towards a scanner for it to be read. Radio frequency identification, by contrast, doesn’t require line of sight. RFID tags can be read as long as they are within range of a reader. Bar codes have other shortcomings as well. If a label is ripped, soiled or falls off, there is no way to scan the item. And standard bar codes identify only the manufacturer and product, not the unique item. The bar code on one milk carton is the same as every other, making it impossible to identify which one might pass its expiration date first.

Will RFID replace bar codes?

Probably not, Bar codes are inexpensive and effective for certain tasks. It is likely that RFID and bar codes will coexist for many years.

Is RFID new?

RFID is a proven technology that's been around since at least the 1970s. Up to now, it's been too expensive and too limited to be practical for many commercial applications. But if tags can be made cheaply enough, they can solve many of the problems associated with bar codes. Radio waves travel through most non-metallic materials, so they can be embedded in packaging or encased in protective plastic for weather-proofing and greater durability. And tags have microchips that can store a unique serial number for every product manufactured around the world.

If RFID has been around so long and is so great, why aren’t all companies using it?

Many companies have invested in RFID systems to get the advantages they offer. These investments are usually made in closed-loop systems—that is, when a company is tracking goods that never leave its own control. That’s because all existing RFID systems use proprietary technology, which means that if company A puts an RFID tag on a product, it can’t be read by Company B unless they both use the same RFID system from the same vendor. But most companies don’t have closed-loop systems, and many of the benefits of tracking items come from tracking them as they move from one company to another and even one country to another.

Constant Pointers:

A constant pointer is a pointer that cannot change the address its holding.

In other words, we can say that once a constant pointer points to a variable then it cannot point to any other variable.

Declaration of constant pointer:

<type of pointer> * const <name of pointer>

An example:

                int * const ptr;

An example program:


int main()


    int n1 = 0, n2 = 0;

    int *const ptr = &n1;

    *ptr = 100;//valid

    ptr = &n2;//Invalid

    printf("%d\n", *ptr);


In the above example:

We declared two variables n1 and n2 and constant pointer ‘ptr’ was declared and made to point n1. Next, ptr is made to point n2,   then print the value at ptr, but as per the constant pointer the pointer pointing an address cannot be change, so we will get the error mentioned below

“ error: assignment of read-only variable ‘ptr’

           ptr = &n2; ”

but we can change the value at the pointer.

Pointer to Constant:

A pointer to a constant is a pointer that cannot change the value of the address its holding through the pointer.

Declaration of pointer to a constant:

<type of pointer> const * <name of pointer>


const <type of pointer>* <name of pointer>

An example:

                int const*ptr;


                const int *ptr;

An example program:


int main()


    int n1 = 0, n2 = 0;

    const int *ptr = &n1;

    *ptr = 100;//Invalid

    printf("%d\n", *ptr);//Invalid

    ptr = &n2;//valid

    printf("%d\n", *ptr);


In the above example:

                We declared two variables n1 and n2 and a pointer to constant ‘ptr’ was declared and made to point n1. Next, ptr is made to dereference, then print the value at ptr, but as per the pointer we cannot dereference, so we got the error mentioned below

  error: assignment of read-only location ‘*ptr’

     *ptr = 100;//Invalid

But we can change the address of the pointer.

Both pointer to constant and constant pointer:

                Both pointer to constant and constant pointer is a pointer that cannot change the address its holding and cannot dereference the value also.

Declaration of constant pointer:

const <type of pointer> * const <name of pointer>

An example:

                const int * const ptr;

An example program:


int main()


    int n1 = 20, n2 = 10;

    const int *const ptr = &n1;

    printf("%d\n", *ptr);//20

    *ptr = 100;//Invalid

    ptr = &n2;//Invalid



In the above example:

    We declared two variables n1 and n2 , here pointer to constant and constant pointer ‘ptr’ was declared and made to point n1. Next, ptr is made to point n2,   then print the value at ptr, and change the address and dereference the value, both are violating the rules, so we will get the error mentioned below

 “ error: assignment of read-only location ‘*ptr’

     *ptr = 100;//Invalid


 error: assignment of read-only variable ‘ptr’

     ptr = &n2;//Invalid ”


mixpanel.track("Video play");