Building and Running Sample Application

This section describes all the steps required to build a DHCPc-based application. The instructions provided in this section are not intended for any particular toolchain, but instead are described in a generic way that can be adapted to any toolchain.

The best way to start building a  DHCPc-based project is to start from an existing µC/TCP-IP project. 

Working project with µC/TCP-IP

The first step before including the µC/DHCPc is to have a working project with the µC/TCP-IP. As previously mentioned, Micriµm may offer starting example with µC/OS-III kernels and µC/TCP-IP and even with µC/DHCPc for many evalboards. 

If no project that include µC/TCP-IP is available, you should follow the µC/TCP-IP Getting Started Guide to ensure to have a working project which use fix IP address before installing µC/DHCPc. Then you can follow the following steps to build and run a first µC/DHCPc example application.

Including Additional Modules to the Project

Once you have a working project with your RTOS and µC/TCP-IP additional modules are needed by the Micriµm DHCP client that are not necessarily already included in your project. Therefore, be sure to add µC/CPU, µC/LIB, and µC/TCP-IP to your project.  

Refer to the following manuals for further information about MIcrium modules:

µC/TCP-IP Documentation

µC/OS-II Documentation

µC/OS-III Documentation

µC/LIB Documentation

µC/CPU Documentation

Including µC/DHCPc Source Code

Include the following files in your project tree from the µC/DHCPc source code distribution, as indicated in Figure - µC/DHCPc Source Code

µC/DHCPc Source Code



As indicated in the Figure - µC/DHCPc Source Code, all the files in the Source folder must be added to your project tree. Furthermore, dhcp-c_os.c/h files of the selected RTOS must be added. 

Compiler settings

Finally, add the following include paths to your project’s C compiler settings:

\Micrium\Software\uC-DHCPc
\Micrium\Software\uC-DHCPc\OS\<OS type>
\Micrium\Software\uC-TCPIP
\Micrium\Software\uC-<OS-Version>


Copying and Modifying Template Files

Copy the files from the uC-DHCPc configuration folder into your application as illustrated in:

Figure - Copying Template Files


dhcp-c_cfg.h is a configuration file used to set up µC/DHCPc module static parameters  and features such as ports, timeout, broadcast bit and so on. Refer to section Module Configuration for more details on all the configurations inside dhcp-c_cfg.h 

Adding µC/DHCPc application function

Before running the example application, you will need to add the new function call, in your app.c file to initialize and setup the µC/DHCPc module. Section Example Application gives an example of how to initialize µC/DHCPc and start DHCP negotiation on an interface. 

This code example will need to be modified in accordance with your project setup. 

Adding Additional includes

Since the µC/TCP-IP module was added to the example project, the following include must be added to the app.c file :

#include <Source/dhcp-c.h>