A Framework For Developing A Microchip PIC Microcontroller Based Applications
A Framework For Developing A Microchip PIC Microcontroller Based Applications
A Framework For Developing A Microchip PIC Microcontroller Based Applications
Abstract: - This paper presents a framework for developing applications based on a Microchip PIC
microcontroller (μC). Consisting of hardware and software tools it supports the development and transfer of
program code from a personal computer to the microcontroller, and evaluation of its execution on rapid
prototyping hardware. The first part of the paper focuses on hardware design, which is based on a modular
approach, i.e. recomposed for the design of each application, in order to ensure maximum adaptability. The
MPIC development system (MPICds) thus consists of a programmer, a main board including adapters for a
variety of chip packages, and plug-in modules. All these hardware components are designed so that they can be
fabricated by any potential user. Selected microcontroller is programmed in the standard ICSP mode using one
of the freely available PC programs. These are presented in the second part of the paper describing the software
part of the framework, which besides programming tools also discusses the code development tools. The stress
is given to the use of high-level tools, where the algorithms are described in the form of different graphical
notations, i.e. block diagrams, instead in C or assembly code. Throughout the paper, a special attention is given
to the use of framework in the electrical engineering education process. Besides giving some suggestions for
the use at different educational levels, the emphasis is on the implication of contemporary design methods, and
the hardware’s robust design, which is deliberately planned in such a way that even an incorrect use cannot
harm any of its components.
Key-Words: - PIC microcontrollers, Development system, High-level design tools, Electrical engineering
education
Recognizing and acting upon the paradigm shifts in 2 Embedded system design cycle
the design of contemporary systems thus calls for Due to dramatically increasing complexity of
novel pedagogical approaches that should be embedded systems over the past decades,
supported by suitable hardware and software tools developers are facing ever-increasing challenges for
[1]. For that reason we designed a framework their products to stay market competitive [8]. In this
aiming to ease and quicken this process. Its context the utilization of systematic design methods
hardware part is the MPIC development system is essential in order to aggregate rather than trade-
(MPICds) with modular structure [7]. This means off the technical, cost, and time-to-market feasibility
that it is recomposed for each application separately. factors [5, 9].
The main hardware parts are the main board with Typically, design cycle steps can be illustrated
the attached microcontroller and the programmer using a V-diagram representation. Several versions
used to download the firmware from a personal from different industry fields can be found in the
computer (PC) to a microcontroller. In addition to literature, but here we refer to the one applied to the
these two major hardware parts several typical plug- design of embedded systems [5]. As depicted in Fig.
in test modules have been designed, intended for the 1, the general progression of the design steps in time
verification of developed programs. The is indicated from left to right. Hence the horizontal
framework’s software tools can be divided into axis of the diagram can be thought of as time, but
those for program code development, and those for since the design is often an iterative process, the
programming the microcontrollers. In the latter actual development rather cycles between left and
group only freely available programs were right leg of the diagram than proceeds linearly
considered, while in the case of development tools through the steps [10]. The vertical axis represents
we focus on those offering high-level design, with the level of system components’ abstraction, with
the algorithms described in the form of different the top steps representing high-level system view
graphical representation (e.g. block diagrams, and the bottom steps representing very low-level
flowcharts) rather than written in C or assembly processes.
code. The design starts with specifying the system
The rest of the paper is organized as follows. In requirements. These are than processed, and the
Section 2 a general embedded system design cycle system is along the left, the decomposition leg of the
is briefly introduced. The main characteristics of the V-diagram, split into smaller pieces. At the bottom
framework’s hardware parts, i.e. the MPIC of the V-diagram is the implementation stage,
development system, are presented in Section 3, representing the transition from decomposition back
while the software parts are described in Section 4. to re-composition proceeding up along the right leg
The frameworks’ appropriates for educational of the V-diagram. Here the system’s entities are
purposes is discussed in Section 5. Finally, Section combined back into larger pieces, resulting in a
6 concludes the paper with the ideas and plans for finally assembled system. The goal of each design
further developments of the framework. process is a system working according to the
specifications, with the V-diagram as narrow as
possible, thereby reducing the time and available on the market at relatively affordable
consequently the cost of design [10]. The prices. Moreover, we can choose from a wide range
framework presented in this paper aids narrowing of quality development and programming
the embedded system design V-diagram by supporting tools (even freely available), while the
providing a common set of tools that are used transfer of the firmware can be always performed
through the prototyping, implementation and testing using the same interface. Lastly, they are also very
stages. In prototyping stage first a simulation model popular in hobby electronic, which may also be an
is designed that behaves according to the important factor for educational equipment. The
requirements. Then for the validation of feasibility, following assumptions and limitations that were
taken into account when designing the MPIC
the design components are prototyped on general
development system:
prototyping hardware. The timing characteristics are
▪ Since the application’s software development is
not modelled in this step, and may change in the
usually a cyclic process of writing and testing the
actual design. Once the components behave
program code, its downloading to a μC as well
appropriately, the on-target prototyping is employed
as verification should be supported.
on the envisaged processing device, in our case a ▪ The system must be structured in a modular
microcontroller. Characteristics of code compiler, fashion to assure maximum flexibility and rapid
fixed-point precision effects and interactions among prototyping.
the system’s components are validated in this step. ▪ No pre-programmed chips should be used in the
When all simulations and prototyping shows the design.
correct operation of a design, a highly optimized ▪ All the basic accompanying software tools
code is produced in the implementation stage. should be freely available on the Internet.
Finally, in the testing stage the design is evaluated ▪ The choice of microcontrollers should be limited
while moving up along the right leg of the V- to those where the transfer of the firmware can
diagram. Configurations such as software-in-the- be performed using ICSP (In-Circuit Serial
loop, processor-in-the-loop, and hardware-in-the- Programming) module (a property of a great
loop are used in the proceeding steps [8]. majority of PIC microcontrollers) [15].
▪ The selection of microcontrollers is further
restricted to those available in the PDIP package
types [15].
3 MPIC development system
▪ The programmer must offer a possibility to
The intention of the MPICds [7] is not to compete
download a firmware from PC to microcontroller
with the commercially available platforms, but
using parallel (LPT) or serial (COM) port.
rather trying to efficiently combine freely available
▪ The programmer must be designed in such way
tools and easily accessible components. Likewise, as
that it can be permanently connected to the main
an educational tool like E-blocks [11] or MILES
board, i.e. when programming or running the
[12], the system is not meant for any particular
application.
curriculum, but can be readily adapted to any
▪ All microcontroller’s I/O pins must be accessible
secondary school or university course. Because of
on the main board plug-in module connectors.
its modular concept it is also very appropriate for
▪ All printed circuit boards (PCB) should be
self-learning as it allows construction of actually
single-sided to allow easy fabrication by
required components, thus reducing the cost of the
potential users.
system.
▪ Where needed the setting of microcontroller’s
In the following subsections the assumptions
operation using external signals should be
taken into account when designing the MPICds and
accessible through jumpers or short-circuit
its key hardware parts are described more in detail.
connections.
▪ Plug-in modules must be designed in such a way
that even their incorrect use does not harm any of
3.1 Design assumptions the system’s components.
Bearing in mind that the MPICds is aimed at These assumptions are based on recognition of
education process the Microchip’s PIC and dsPIC problems and difficulties that beginners in the world
microcontroller families [13] have been selected of microcontrollers are often faced with.
from a range of other microcontroller families from Consequently, the system designed in such way will
different manufacturers due to multiple reasons [1, not result in the most efficient variant, but will
14]. Firstly, these microcontrollers are widely
certainly enable someone to get familiar with the designed. These are connected to the Textool socket
entire design cycle. instead of a 40-pin microcontroller.
The main board includes a power supply with
3.2 Main board Greatz bridge whose intention is dual. The first is to
The main board comprising of a microcontroller be used as a classical full wave bridge, so that input
represents a central part of the development system, voltage can be either AC or DC. The second is to
to which all other system components (i.e. the protect the connected power supply in case the
power source, the programmer, and plug-in programmer has its own power supply connected.
modules) are connected as needed. Its electrical Plug-in modules and the programmer are connected
scheme is depicted in Fig. 2. to the main board through 10-pin IDC connectors.
The microcontroller is attached to the main board One microcontroller’s port with the supply voltage
through a standard 40-pin Textool socket. A is available on each of the IDC connectors for the
limitation to the microcontrollers with up to 40 pins connection of plug-in modules. On the IDC
was made due to the fact that a 40-pin package is connector of the PORTE additionally the
the largest PDIP package type in the case of PIC microcontroller’s pins for the connection of external
microcontrollers. Furthermore, a more frequent reset circuit, external oscillator and external AD
variant of pins arrangement was considered, while converter supply voltage can be accessed. Each
for microcontrollers with different arrangement or microcontroller port is connected to the resistor
lower number of pins, appropriate adapters were chain, which is used to perform either pull-up or
pull-down function. The operation can be set using programming the PIC microcontrollers [18]. It uses
appropriate jumper connections. On the IDC five or six microcontroller pins for writing and
connector for the programmer attachment all pins reading the firmware. The sixth pin must be driven
that are necessary for the connection of ICSP only at microcontrollers which can also be
compatible programmers are available. programmed using a second type of programming
Additionally, on the remaining pins, the procedure, i.e. the Low-Voltage ICSP.
microcontroller’s USART module pins are Electrical scheme of the programmer is depicted
available, that can be used when downloading the in Fig. 3. The circuit consists only of standard
firmware using bootloaders. The programmer’s elements and can be connected to the main board
virtual connection-disconnection to the using IDC connector cable. Similarly to the main
microcontroller is driven manually, using a single board, the programmer has its own power supply for
switch. two additional reasons. The first is to protect the
Places for the RC and quartz crystal oscillator are microcontroller against damages during
also foreseen on the printed circuit board. A simple programming using a build in 100 mA current limit,
reset circuit with a key as an execution unit is also and the second is simply to enable its autonomous
designed so that it does not disturb the ICSP use, e.g. for programming the microcontroller
programmer activity. already attached to the end application. For such
cases a Microchip compliant FCC connector is
foreseen on the printed circuit board.
3.3 Programmer The main programmer’s element bridging the PC
Three particularly important design assumptions and microcontroller is the high-speed CMOS
were taken into account when designing a integrated circuit 74HCT367. It contains six three-
programmer’s hardware part. These are that the state non-inverting buffers, which are driven by two
microcontrollers must be programmable in the ICSP enable inputs. Using those, the firmware is
mode, that the firmware download can be performed transmitted from the PC to a microcontroller and
using serial or parallel PC port, and that the vice versa. The circuit additionally contains some
accompanying software programming tools are other elements from which the transistors and Zener
freely available on the Internet. Programmer is diodes should be exposed. The latter serve for the
therefore designed to be compatible with the JDM adaptation of the COM port voltage levels, which in
[16] and P16PRO [17] programmers, where the contrast to LPT port are not TTL compatible. The
download of the firmware is in the case of JDM transistors are used either to assure appropriate
programmer achieved using COM port, while the current loads or to convert the voltage levels, since
P16PRO uses LPT port. ICSP is a synchronous in the ICSP programming mode voltages higher
procedure specified by Microchip and used for than 5 V have to be generated.
Microsystems, vol. 23, iss. 5, October 1999, pp. [24] –, Simulink, The MathWorks Inc., http://www.
281-290. mathworks.com/products/simulink/, December
[15] –, Product Selector Guide 2005 (DS00148K2), 2007.
Microchip Technology Inc., 2005. [25] –, Embedded Target for 16 bits PIC,
[16] –, PIC-Programmer, http://www.jdm.homepage http://www.kerhuel.eu/RTWdsPIC/, December
.dk/newpic.htm, December 2007. 2007.
[17] –, P16PRO and PICALL, http://picallw.feniks- [26] –, FLEX: Microchip dsPIC evaluation board,
pro.com/, December 2007. Evidence, http://www.evidence.eu.com/content/
[18] –, PICmicro 18C Family Reference Manual – view/114/204/, December 2007.
In-Circuit Serial Programming (DS39531A), [27] –, Scilab: The open source platform for
Microchip Technology Inc., 2004. numerical computation, INRIA, http://www.
[19] –, MPLAB IDE User's Guide (DS51519B), scilab.org/, December 2007.
Microchip Technology Inc., 2006. [28] –, Scicos: Scilab's block diagram
[20] –, PICC compiler, HI-TECH Software, modeler/simulator, INRIA, http://www.scicos.
http://www.htsoft.com/products/compilers/picc org/, December 2007.
compiler.php, December 2007. [29] –, IC-Prog Prototype Programmer,
[21] –, IAR Embedded Workbench, IAR Systems, http://www.ic-prog.com/, December 2007.
http://www.iar.com/, December 2007. [30] –, WinPic - A PIC Programmer for Windows,
[22] –, CCS C Compiler, CCS Inc., http://www. http://freene-thomepage.de/dl4yhf/winpicpr.html,
ccsinfo.com/, December 2007. December 2007.
[23] –, mikroC compiler, mikroElektronika, [31] W.A. Stapleton, Microcomputer Fundamentals
http://www.mikroe.com/en/compilers/mikroc/ for Embedded Systems Education, 36th
pic/, December 2007. ASEE/IEEE Frontiers in Education
Conference, October 2006.