Download as pdf or txt
Download as pdf or txt
You are on page 1of 34

CodeBlocks IDE

User Guide

JN-UG-3028
Revision 1.1
7-Feb-2007
Jennic
CodeBlocks IDE
User Guide

2 © Jennic 2007 JN-UG-3028 v1.1


Jennic
CodeBlocks IDE
User Guide

Contents
About this Manual 4
Organisation 4
Conventions 5
Acronyms and Abbreviations 5
Related Documents 5
Feedback Address 5
1 Overview 7
2 Installing Code::Blocks 9
2.1 Pre-requisites 9
2.2 Installation Procedures 10
2.2.1 Complete or Typical Installation 11
2.2.2 Custom Installation 13
2.3 Configuring the Integrated Flash Programmer 16
3 QuickStart to Using Code::Blocks 19
3.1 Example Applications 19
3.2 Opening and Building an Example Project 20
4 Creating and Building Your Own Projects 21
4.1 Code::Blocks Projects 21
4.2 Creating a Project 22
4.3 Working On Your Project 26
4.4 Building Your Project 27
4.4.1 Specifying Paths 27
4.4.2 Performing a Build 29
4.4.3 Dealing with Compilation Errors 30
5 Downloading an Application Binary 31
5.1 Pre-requisites 31
5.2 Download Procedures 31
5.2.1 Using the Integrated Flash Programmer 32
5.2.2 Using a Separate Flash Programmer 32

JN-UG-3028 v1.1 © Jennic 2007 3


Jennic
CodeBlocks IDE
User Guide

About this Manual


This User Guide is designed to help you use the Code::Blocks IDE (Integrated
Development Environment) to develop applications for devices in the Jennic
wireless microcontroller family. The guide focuses on tasks required to implement
applications on Jennic devices and does not cover all the features and functionality
of Code::Blocks.

! Caution: This User Guide refers to Jennic’s version of


Code::Blocks. It should not be used in conjunction with any other
version of Code::Blocks.

Organisation
This manual consists of five chapters, as follows:
• Chapter 1 provides a brief overview of using the Code::Blocks IDE.
• Chapter 2 describes how to install Code::Blocks, downloaded from the Jennic
web site.
• Chapter 3 provides a quick start to using Code::Blocks by describing how to
use the IDE to open and build example applications supplied by Jennic.
• Chapter 4 describes how to create and build your own Code::Blocks projects,
and provides advice on dealing with compilation errors.
• Chapter 5 describes how to download your executable code to the Flash
memory of the Jennic wireless microcontroller.

Note: Once you have installed and configured Code::Blocks, you


are advised to practise using the IDE with the example
applications (as described in Chapter 3) before creating and
building your own projects.

4 © Jennic 2007 JN-UG-3028 v1.1


Jennic
CodeBlocks IDE
User Guide

Conventions
Files, folders, functions and parameter types are represented in bold type.
Function parameters are represented in italics type.
Code fragments are represented in the Courier typeface.

Acronyms and Abbreviations


IDE Integrated Development Environment
SDK Software Developer’s Kit

Related Documents
[1] Jennic Software Developer’s Kit Installation Guide (JN-UG-3035)
[2] Jennic JN51xx Flash Programmer Application User Guide (JN-UG-3007)

Feedback Address
If you wish to comment on this manual, or any other Jennic user documentation,
please provide your feedback by writing to us (quoting the manual reference number
and version) at the following postal address or e-mail address:
Applications
Jennic Ltd
Furnival Street
Sheffield S1 4QT
United Kingdom
doc@jennic.com

JN-UG-3028 v1.1 © Jennic 2007 5


Jennic
CodeBlocks IDE
User Guide

6 © Jennic 2007 JN-UG-3028 v1.1


Jennic
CodeBlocks IDE
User Guide

1 Overview
For developing applications in an IDE (Integrated Development Environment),
Jennic recommends the use of Code::Blocks. This is a full-featured, open source
IDE which is available free-of-charge. When developing applications for the Jennic
wireless microcontrollers, you should use the specially adapted version of
Code::Blocks available from Jennic.
This version of Code::Blocks can be installed using either of two installers:
• Code::Blocks installer (part code: JN-SW-4024): Use this installer if you just
want to install/update Code::Blocks and associated software. This is the
installation method described in Chapter 2 of this manual. The installer is
available from the Support area of the Jennic web site
(www.jennic.com/support).
• “SDK with IDE” installer (part code: JN-SW-4026): Here, Code::Blocks is
installed as part of the Jennic Software Developer’s Kit (SDK) installation. Use
this installer if you want to install the SDK and Code::Blocks at the same time.
This installation is described in the Jennic Software Developer’s Kit Installation
Guide (JN-UG-3035). The installer is available on the:
Jennic evaluation kit CDs
Support area of the Jennic web site (www.jennic.com/support)

! Caution: Use the instructions provided in this manual only with


the Jennic version of Code::Blocks.

This manual describes how to:


• Install Code::Blocks using the dedicated installer (part code: JN-SW-4024)
downloaded from the Jennic web site (the software is automatically configured
to use the Jennic JN51xx Compiler)
• Create a Code::Blocks project for your application
• Edit your application code, as required, using the Code::Blocks editor
• Build your application, to produce a binary file
• Download your binary file to the device that is to run the application

Note: Before creating and building your own projects, you are
recommended to follow the instructions in Chapter 3 to practise
using Code::Blocks with the example applications available on
the Jennic web site.

JN-UG-3028 v1.1 © Jennic 2007 7


Jennic
CodeBlocks IDE
User Guide

8 © Jennic 2007 JN-UG-3028 v1.1


Jennic
CodeBlocks IDE
User Guide

2 Installing Code::Blocks
This chapter describes how to install the Jennic version of Code::Blocks that has
been downloaded from the Support area of the Jennic web site
(www.jennic.com/support).

Note: This chapter only covers installation using the Jennic


Code::Blocks installer (part code: JN-SW-4024) downloaded from
the Jennic web site.

Note: If you wish to install the Code::Blocks IDE together with the
Jennic SDK (for IEEE 802.15.4 or ZigBee), you are advised to
use the Jennic “SDK with IDE” installer (part code: JN-SW-4026).
This installer is available on the evaluation kit CD or from the
Support area of the Jennic web site (www.jennic.com/support).
This installation is included in the Jennic Software Developer’s Kit
Installation Guide (JN-UG-3035).

2.1 Pre-requisites
Before installing Code::Blocks, ensure that you have the following:
• A machine with the following specification:
Windows XP or 2000 operating system
At least 150 MB of hard disk space available
• Administrator rights on the machine
• The Code::Blocks .msi file, downloaded from the Jennic web site (the filename
is of the form JN-SW-4024-JennicCodeblocks-XvY.msi).

! Caution: Your machine must not contain a previous installation


of Code::Blocks. If it does, you must uninstall this software before
installing the version of Code::Blocks described in this manual.

JN-UG-3028 v1.1 © Jennic 2007 9


Jennic
CodeBlocks IDE
User Guide

2.2 Installation Procedures


Installation of Code::Blocks is performed using a set-up wizard (provided by Jennic)
which is able to install three software components:
• Code::Blocks IDE
• Jennic JN51xx Compiler
• Jennic JN51xx Flash Programmer
Two installation procedures are presented in the sub-sections below. The required
procedure depends on the software that already exists on your machine.
• If none of the above software components exists on your machine, follow the
procedure for a Complete installation in Section 2.2.1.
• If the Jennic JN51xx Compiler (or any previous Jennic Cygwin installation)
and/or JN51xx Flash Programmer already exist on your machine, follow either:
the procedure for a Typical installation in Section 2.2.1, or
the procedure for a Custom installation in Section 2.2.2.

10 © Jennic 2007 JN-UG-3028 v1.1


Jennic
CodeBlocks IDE
User Guide

2.2.1 Complete or Typical Installation


This procedure provides a “Complete” installation or a “Typical” installation of
Code::Blocks, as required:
• Complete installation: Installs Code::Blocks and associated software
components - the Code::Blocks IDE, the JN51xx Compiler and the JN51xx
Flash Programmer application.
• Typical installation: Installs only Code::Blocks.

! Caution: The Complete installation assumes that none of the


above software components exists on your machine. If any of the
components are already installed, you must either first remove
them or use the Custom installation procedure in Section 2.2.2.

To install Code::Blocks on your machine:


Step 1 In Windows Explorer, browse to the Code::Blocks .msi file on your machine and
double-click on the file (name format JN-SW-4024-JennicCodeblocks-XvY.msi).
This launches Jennic’s set-up wizard for Code::Blocks.
Step 2 Follow the on-screen instructions of the set-up wizard until you reach the screen
which lists the possible set-up types: Typical, Custom, Complete.

JN-UG-3028 v1.1 © Jennic 2007 11


Jennic
CodeBlocks IDE
User Guide

Step 3 Consult the note below, then select either Typical or Complete, as required, and
click Next.

Note: For Typical and Complete installations, the set-up wizard


installs the software in the directory C:\Jennic\cygwin\jennic\. If
you wish to specify a different installation location, select Custom
and continue from Step 3 of the custom installation procedure
provided in Section 2.2.2.

The installation continues. The set-up wizard installs the software in the directory
C:\Jennic\cygwin\jennic\ and configures the compiler settings in Code::Blocks.
Step 4 When the installation is complete, click Finish.
Step 5 (Optional) Once the Code::Blocks installation has finished, you can install the
required stack software components, as follows:
• 802.15.4 MAC software (JN-SW-4025)
• ZigBee Stack (JN-SW-4011), if the ZigBee option has been purchased
The latest versions of these software components are available for download from
the Support area of the Jennic web site (www.jennic.com/support).
For each of these components, download the relevant .msi file to your machine and
then double-click on the file to start its installation wizard. Again, follow the on-
screen instructions and install the software into the same directory as Code::Blocks.

Note: Even if you have selected the Typical installation, a basic


Flash programmer will be integrated into Code::Blocks, allowing
you to download binary files to Flash memory directly from
Code::Blocks. Once you have completed the above installation
procedure, go to Section 2.3 to configure the Flash Programmer.

! Caution: If you later wish to uninstall Code::Blocks after a


Complete installation, beware that this will also remove Cygwin
components, damaging any pre-existing Cygwin installation.
Therefore, once you have uninstalled Code::Blocks, you will have
to re-install Cygwin, if required.

12 © Jennic 2007 JN-UG-3028 v1.1


Jennic
CodeBlocks IDE
User Guide

2.2.2 Custom Installation


This procedure allows a “Custom” installation of Code::Blocks and its associated
software components. It allows the installation of any combination of the following
components - the Code::Blocks IDE, the JN51xx Compiler and the JN51xx Flash
Programmer application.

Note: You should use this procedure if you already have the
JN51xx Compiler and/or JN51xx Flash Programmer on your
machine. In the case of a re-installation, you must first uninstall
the previous version of the relevant software component.

To install Code::Blocks on your machine:


Step 1 In Windows Explorer, browse to the Code::Blocks .msi file on your machine and
double-click on the file (name format JN-SW-4024-JennicCodeblocks-XvY.msi).
This launches Jennic’s set-up wizard for Code::Blocks.
Step 2 Follow the on-screen instructions of the set-up wizard until you reach the screen
which lists the possible set-up types: Typical, Custom, Complete.

JN-UG-3028 v1.1 © Jennic 2007 13


Jennic
CodeBlocks IDE
User Guide

Step 3 Select Custom, then click Next.


The Custom Setup screen is now displayed.

Step 4 Fill in the Custom Setup screen, as follows:


a) If there is a software component that you do not wish to install (because it
already exists on your machine), left-click on the icon next to the relevant
software item to obtain the pop-up menu, then select the option Entire feature
will be unavailable.
A red cross should now appear to the left of the software item, as shown below:

b) The installation location for the software is shown in the Location field. The set-
up wizard will automatically create the installation directory structure at this
point. By default, this is C:\, but you can specify another drive and/or path by
using the Browse button to navigate to the required location.
Step 5 Click Next and when the installation is complete, click Finish.

14 © Jennic 2007 JN-UG-3028 v1.1


Jennic
CodeBlocks IDE
User Guide

Step 6 (Optional) Once the Code::Blocks installation has finished, you can install the
required stack software components, as follows:
• 802.15.4 MAC software (JN-SW-4025)
• ZigBee Stack (JN-SW-4011), if the ZigBee option has been purchased
The latest versions of these software components are available for download from
the Support area of the Jennic web site (www.jennic.com/support).
For each of these components, download the relevant .msi file to your machine and
then double-click on the file to start its installation wizard. Again, follow the on-
screen instructions and install the software into the same directory as Code::Blocks.

Note: Even if you have not installed the JN51xx Flash


Programmer as part of your Custom installation, a basic Flash
programmer will be integrated into Code::Blocks, allowing you to
download binary files to Flash memory directly from
Code::Blocks. Once you have completed the above installation
procedure, go to Section 2.3 to configure the Flash Programmer.

JN-UG-3028 v1.1 © Jennic 2007 15


Jennic
CodeBlocks IDE
User Guide

2.3 Configuring the Integrated Flash Programmer


As part of the Code::Blocks installation, you may have opted to install the JN51xx
Flash Programmer application. Even if you did not select this option, a basic Flash
programmer is included in the Code::Blocks installation. In either case, this feature
allows you to download your binary code to the target device from within
Code::Blocks. Before using this facility, you must check/modify its configuration, as
described below.

Note: If you do not wish to use the integrated Flash programmer,


you can ignore this section.

To check/modify the configuration of the integrated download feature:


Step 1 In Code::Blocks, follow the menu path Tools>Configure tools.
This displays a list of user-defined tools.
Step 2 Select the Download to Flash tool and click Edit.
The Edit tool screen is displayed.

The fields of this screen are pre-filled with the relevant information, as shown above.

16 © Jennic 2007 JN-UG-3028 v1.1


Jennic
CodeBlocks IDE
User Guide

The fields are briefly as follows:


• Name: The name of the tool (Download to Flash) to appear in the Tools
menu in Code::Blocks.
• Executable: The path to the executable for the download tool.
• Parameters: Specifies the name of the binary file to be downloaded and the
communications port to use. When working on a project, {PROJECT_NAME} is
automatically substituted with the Code::Blocks project name.
• Working directory: Specifies the location of the binary file to be downloaded.
{PROJECT_DIR} is automatically substituted with the Code::Blocks project
directory. By default, the contents of this field point to the debug binary.
Step 3 In the Edit tool screen, perform the following checks:
a) In the Parameters field, ensure that the communications port setting is 1 (in
–f ${PROJECT_NAME}.bin –c 1, the ‘1’ is the comm port setting).
b) In the Working directory field, check that the correct directory is shown for
your download. For example, if the default Debug directory is shown but you
wish to download a release binary, change this directory to Release by
overtyping Debug.
c) In Launching options, ensure that the first option is selected (as shown
above).
Then click OK.

JN-UG-3028 v1.1 © Jennic 2007 17


Jennic
CodeBlocks IDE
User Guide

18 © Jennic 2007 JN-UG-3028 v1.1


Jennic
CodeBlocks IDE
User Guide

3 QuickStart to Using Code::Blocks


This chapter provides a quick start to using Code::Blocks through the example
applications available from Jennic.

Note: You are advised to practise using Code::Blocks with these


examples before you use the IDE with your own applications.

3.1 Example Applications


Example applications are available for download from the Support area of the Jennic
web site (www.jennic.com/support). The examples can be found under
Application Notes. For each example application, the source application code and
an accompanying note are contained in a ZIP file.
The examples include:
• Light Switch Application (JN-AN-1002): A basic wireless light switch based
on the IEEE 802.15.4 protocol stack.
• Serial Cable Replacement using 802.15.4 (JN-AN-1005): A wireless UART
link that uses two sensor boards from the Jennic evaluation kits.
• ZigBee Wireless Sensor Network (JN-AN-1015): A basic Wireless Sensor
Network (WSN) that uses the Jennic ZigBee stack and evaluation kit
hardware.

JN-UG-3028 v1.1 © Jennic 2007 19


Jennic
CodeBlocks IDE
User Guide

3.2 Opening and Building an Example Project


Once you have downloaded an example application from the Jennic web site:
Step 1 Unzip the example application into one of the following directories:
• If you are using the latest Jennic SDK version, the target directory is normally
C:\Jennic\cygwin\jennic\SDK\
• If you are using an earlier Jennic SDK version, the target directory may be
C:\Jennic\cygwin\jennic\developer\
A .cbp file is located in the Build sub-directory - this is the Code::Blocks project file
for the application.
Step 2 Run Code::Blocks.
Step 3 Open the .cbp project file by following the menu path File>Open and browsing for
the file.
This opens the .c source file and any other files specified in the project. The
compiler and paths to use are also defined.
Step 4 Check which compiler is set, as follows:
a) Follow the menu path Project>Build options to display the Project build
options screen.
b) Click on the project name at the top of the tree displayed in the left pane of the
screen.
c) Check the Selected compiler field – this should show the JN51xx Compiler. If
not, select it from the drop-down list.
Step 5 Make any required edits to the code, using Code::Blocks as the editor.
Step 6 Build the example by following the menu path Build>build.
This generates a .bin file in the Build directory.

Note: To download the .bin file to the target device, refer to


Chapter 5.

20 © Jennic 2007 JN-UG-3028 v1.1


Jennic
CodeBlocks IDE
User Guide

4 Creating and Building Your Own Projects


This chapter describes how to create and then build your own applications. It is
assumed that you have installed Code::Blocks as described in Chapter 2. Before
working on your own applications, you are recommended to practise using the IDE
with the example projects provided by Jennic, as described in Chapter 3.

Note: The Jennic installation of Code::Blocks puts a file called


default.conf on the C drive of your computer, in the directory
Documents and Settings\<user>\Application Data\
codeblocks. This file is used to pre-configure the JN51xx
Compiler with the appropriate program files and paths.

4.1 Code::Blocks Projects


In Code::Blocks, an application under development is termed a project. In order to
develop an application, you must first create a project for it. This involves creating a
project directory.

Note: Jennic have simplified the project creation process by


providing a wizard which can be selected when project creation is
first entered.

As part of the project creation process, Code::Blocks creates a project file, with
extension .cbp. This is put into the project directory, along with the C source file(s).
The project file contains essential project information, such as all required directory
paths and the compiler to use for building the application.
Once created, a project can be displayed and manipulated in the Projects tab in the
Management pane on the left of the Code::Blocks window.
The rest of this chapter describes:
• How to create a Code::Blocks project (see Section 4.2)
• How to work on a project in Code::Blocks (see Section 4.3)
• How to build a project (see Section 4.4)

JN-UG-3028 v1.1 © Jennic 2007 21


Jennic
CodeBlocks IDE
User Guide

4.2 Creating a Project


To create your own project:
Step 1 In Code::Blocks, follow the menu path File>New>Project.
This displays the New from template screen.
Step 2 In this screen, select the Jennic icon (encircled in red below) and then click Go. This
starts the Jennic project wizard.

Note: You can use the Category field to select the Jennic wizard
so that only the Jennic icon is shown.

Step 3 In the first screen of the wizard, simply click Next (and, if desired, tick the checkbox
Skip this page next time).

22 © Jennic 2007 JN-UG-3028 v1.1


Jennic
CodeBlocks IDE
User Guide

Step 4 In the next screen, enter your project information as follows:


a) In the Project title field, enter a name for your project (this is used to create the
project filename – see Substep c below).
b) In the field Folder to create project in, navigate to the appropriate directory as
follows:
If you are using the latest Jennic SDK version, the project area is normally
C:\Jennic\cygwin\jennic\SDK\
If you are using an earlier Jennic SDK version, the project area may be
C:\Jennic\cygwin\jennic\developer\
c) The remaining two fields (Project filename and Resulting filename) are filled
in automatically by the wizard – leave them unchanged!
d) Click Next.

JN-UG-3028 v1.1 © Jennic 2007 23


Jennic
CodeBlocks IDE
User Guide

Step 5 In the next screen, select the JN51xx Compiler and click Next.
Step 6 Now select the environment in which you will work on the application:
• If you are using the latest Jennic SDK version, you will normally work in the
SDK directory:
C:\Jennic\cygwin\jennic\SDK\
• If you are using an earlier Jennic SDK version (from a JN5121 evaluation kit),
you may work in the developer directory:
C:\Jennic\cygwin\jennic\developer\
Then click Next.

Step 7 In the next screen, choose the application type from the following:
• IEEE 802.15.4 application
• ZigBee Co-ordinator application
• ZigBee End Device application
• ZigBee Router application
Then click Next.

24 © Jennic 2007 JN-UG-3028 v1.1


Jennic
CodeBlocks IDE
User Guide

Step 8 Now select the type of board to which the application will be downloaded, from the
following:
• DK1 board (from JN5121-EK000 or JN5121-EK010 evaluation kit)
• DK2 board (from JN513x-EK000 or JN513x-EK010 evaluation kit)
• NTS (Network Test System) board
• High Power Development Kit board
Then click Next.
Step 9 In the next screen, select the type of Jennic wireless microcontroller on which you
will run the application, from the following:
• JN5121
• JN513x
Finally, click Finish.
Your project has been created!

Note: A Code::Blocks project file (with extension .cbp) has been


created in the directory

C:\Jennic\cygwin\jennic\SDK\<project name>

or

C:\Jennic\cygwin\jennic\developer\<project name>

JN-UG-3028 v1.1 © Jennic 2007 25


Jennic
CodeBlocks IDE
User Guide

4.3 Working On Your Project


Once you have created your project, you can work on your application using
Code::Blocks as the editor.
To edit your code, follow the procedure below:
Step 1 If the required project is not already open (if it has been closed since it was created),
open the project by following the menu path File>Open and browsing for the
relevant .cbp project file. This file should be located in the directory
C:\Jennic\cygwin\jennic\SDK\<project name>
or
C:\Jennic\cygwin\jennic\developer\<project name>
Step 2 Click on the Projects tab in the Management pane (on the left of the Code::Blocks
window).
Your project should appear in the list of projects under Workspace.
Step 3 Follow the tree structure for your project until you reach the .c file under sources.
Note that the .c filename does not initially reflect the name of your project.
Step 4 If required, rename the .c source file, as desired, by right-clicking on it in the
Projects tab and selecting Rename file from the pop-up menu.
The Rename file screen appears – enter the new filename and then click OK.

! Caution: You must rename the .c source file before saving it.
Once the file has been saved, the rename option is removed.

Step 5 To display the code in the main pane, double-click on the .c source file in the
Projects tab.
You can now edit the code in the main pane.
Step 6 When you have finished editing the .c source file, ensure that you save your
changes (for example, by following the menu path File>Save) and then close the file
(for example, by following the menu path File>Close file).
You are recommended to save your changes regularly while editing.
Step 7 Once you have finished working on the project, save the project changes (for
example, by following the menu path File>Save project) and close the project (for
example, by following the menu path File>Close project).

26 © Jennic 2007 JN-UG-3028 v1.1


Jennic
CodeBlocks IDE
User Guide

4.4 Building Your Project


This section describes how to prepare for and perform an application build. It also
provides advice on dealing with compilation errors.

4.4.1 Specifying Paths


Before building your application, ensure that you have specified all the necessary
directory paths for the linker and compiler. To do this:
Step 1 Follow the menu path Project>Build options.
The Project build options screen is displayed.
Step 2 Click on the project name at the top of the tree displayed in the left pane of the
screen, and then click on the Directories tab to obtain the view shown below.

Step 3 Click on the Compiler sub-tab and ensure that the paths to all the required header
files are listed. If you need to add a directory path, use the Add button to specify the
new path.
Step 4 Click on the Linker sub-tab and ensure that the path to the linker command file is
C:\Jennic\cygwin\jennic\SDK\Build or C:\Jennic\cygwin\jennic\developer\Build,
as appropriate.

JN-UG-3028 v1.1 © Jennic 2007 27


Jennic
CodeBlocks IDE
User Guide

Step 5 Click on the Linker tab (top-level) to obtain the view shown below.

Step 6 Ensure that the paths to all the necessary link libraries are present in the
Link libraries field. If you need to add a directory path, use the Add button to
specify the new path.
Step 7 Click OK to register any changes and to exit the Project build options screen.

28 © Jennic 2007 JN-UG-3028 v1.1


Jennic
CodeBlocks IDE
User Guide

4.4.2 Performing a Build

! Caution: Before attempting to build your application, make sure


you have specified all the necessary paths for the linker and
compiler, as described above in Section 4.4.1.

To build a finished project:


Step 1 If the required project is not already open then open the project by following the
menu path File>Open and browsing for the relevant .cbp project file. This file
should be located in the directory
C:\Jennic\cygwin\jennic\SDK\<project name>
or
C:\Jennic\cygwin\jennic\developer\<project name>
Step 2 Click on the Projects tab in the Management pane (on the left of the Code::Blocks
window), then browse to and click on the project to be built.
Step 3 Select the required build type, Debug or Release, by following the menu path
Build>Select target.
• If you are building for debug purposes, select Debug
• If you are building for a final release, select Release
Alternatively, you can make this choice using the Build target drop-down list in the
Code::Blocks toolbar.
Step 4 Build the project (for example, by following the menu path Build>build).
Depending on the build type, the output file is put in one of the following sub-
directories:
• <project name>\Build\Debug
• <project name>\Build\Release

Note: During the build, log messages are displayed in the


Build log and Build messages tabs of the Messages pane at
the bottom of the Code::Blocks window.

JN-UG-3028 v1.1 © Jennic 2007 29


Jennic
CodeBlocks IDE
User Guide

4.4.3 Dealing with Compilation Errors


When the Build>Build or Build>Rebuild menu commands are invoked, the JN51xx
Compiler is used to generate a .bin file. If the compiler encounters any errors, the
compilation is stopped and error messages are displayed in the Build log tab in the
Messages pane at the bottom of the Code::Blocks window. The line where the
compiler found the error is marked in the code in the main pane.
When interpreting errors, the following points are worth noting:
• If the error is caused by the omission of a semi-colon or comma then the fault
is usually in the line above the line indicated.
• If the error is generated by the linker then the message will often refer to a
function name preceded by an underscore; e.g. _vAHI_DioSetDirection.
This would suggest that a required file is missing in the project or a file cannot
be found on the specified path. To include a specific file, follow the menu path
Project >Add files and add the file into the project.
Once you have corrected any errors, use Build>Rebuild to re-build your project.

30 © Jennic 2007 JN-UG-3028 v1.1


Jennic
CodeBlocks IDE
User Guide

5 Downloading an Application Binary


Once you have built your project, you must download the binary output to the Flash
memory in the wireless microcontroller of the device that is to run the code. This
chapter outlines how to perform the download.

5.1 Pre-requisites
Ensure that you have the following:
• A target device containing a Jennic wireless microcontroller.
• A serial cable and dongle allowing connection between your PC and the target
device.
• The .bin file to be downloaded – following a build, this file is placed in the
Build\Release or Build\Debug directory for the project, as appropriate.

5.2 Download Procedures


You must use a Flash programmer to download your application’s binary file to the
Flash memory of the JN51xx on the target device.
• If you wish to use the Flash programmer integrated into Code::Blocks, refer to
Section 5.2.1.
• If you wish to use a separate installation of the JN51xx Flash Programmer,
refer to Section 5.2.2.

JN-UG-3028 v1.1 © Jennic 2007 31


Jennic
CodeBlocks IDE
User Guide

5.2.1 Using the Integrated Flash Programmer


The version of Code::Blocks provided by Jennic includes an integrated Flash
programmer that allows you to download your binary file to the target device from
within Code::Blocks. Depending on the option chosen during installation, this
integrated feature may be the full JN51xx Flash Programmer or a more basic Flash
programmer.

! Caution: Before using the integrated Flash programmer, it must


be configured as described in Section 2.3.

To download your .bin file to a device:


Step 1 In Code::Blocks, follow the menu path Tools>Download to Flash.
The following screen is displayed:

Step 2 Connect the cable from your PC to the target device.


Step 3 Power-cycle the target device by switching it OFF then ON.
Step 4 To start the download, press the Enter (or Return) key on your keyboard.
Step 5 Once the download has finished, remove the cable and power-cycle the device.

5.2.2 Using a Separate Flash Programmer


If you wish to use a separate installation of the JN51xx Flash Programmer, refer to
the procedure for downloading binary code in the Jennic JN51xx Flash Programmer
Application User Guide (JN-UG-3007).

32 © Jennic 2007 JN-UG-3028 v1.1


Jennic
CodeBlocks IDE
User Guide

Revision History
Version Date Description

1.0 29-Nov-2006 First release

1.1 07-Feb-2007 Updated to cover both JN5121 and JN513x series devices

Disclaimer
The contents of this document are subject to change without notice. Customers are advised to consult with JENNIC commercial
representatives before ordering.

The information and circuit diagrams in this document are presented as examples of semiconductor device applications, and are not
intended for incorporation in devices for actual use. Also, JENNIC is unable to assume responsibility for infringement of any patent
rights or other rights of third parties arising from the use of this information or circuit diagrams.

No license is granted by its implication or otherwise under any patent or patent rights of JENNIC Ltd
“Typical” parameters that are provided in this document may vary in different applications and performance may vary over time. All
operating parameters must be validated for each customer application by the customer’s own technical experts.

! Customers considering the use of our products in special


applications where failure or abnormal operation may directly
affect human lives or cause physical injury or property damage,
or where extremely high levels of reliability are demanded (such
as aerospace systems, atomic energy controls, vehicle operating
controls, medical devices for life support, etc.) are requested to
consult with JENNIC representatives before such use. JENNIC
customers using or selling products incorporating JENNIC IP for
use in such applications do so at their own risk and agree to fully
indemnify JENNIC for any damages resulting from such improper
use or sale.

JN-UG-3028 v1.1 © Jennic 2007 33


Jennic
CodeBlocks IDE
User Guide

Corporate Headquarters Japan Sales Office Taiwan Sales Office


Furnival Street Osakaya building 4F 19F-1, 182, Sec.2
Sheffield 1-11-8 Higashigotanda Tun Hwa S. Road
S1 4QT Shinagawa-ku, Tokyo Taipei 106
United Kingdom 141-0022, Japan Taiwan
Tel +44 (0)114 281 2655 Tel +81 3 5449 7501 Tel +886 2 2735 7357
Fax +44 (0)114 281 2951 Fax +81 3 5449 0741 Fax +886 2 2739 5687
E-mail info@jennic.com E-mail info@jp.jennic.com E-mail info@tw.jennic.com

United States Sales Office United States Sales Office Korean Sales Office
1322 Scott Street, Suite 203 1060 First Avenue, Suite 400 701, 7th Floor, Kunam Building
Point Loma King of Prussia 831-37, Yeoksam-Dong
CA 92106 PA 19406 Kangnam-ku
USA USA Seoul 135-080
Korea
Tel +1 619 223 2215 Tel +1 619 223 2215
Fax +1 619 223 2081 Fax +1 619 223 2081 Tel +82 2 552 5325
E-mail info@us.jennic.com E-mail info@us.jennic.com Fax +82 2 3453 8802
E-mail info@kr.jennic.com

34 © Jennic 2007 JN-UG-3028 v1.1

You might also like