You are on page 1of 16

8/9/2016

ĐẠI HỌC QUỐC GIA TP.HỒ CHÍ MINH


TRƯỜNG ĐẠI HỌC BÁCH KHOA
KHOA ĐIỆN-ĐIỆN TỬ
BỘ MÔN KỸ THUẬT ĐIỆN TỬ

Embedded System Design


Chapter 6: Development tools

6.1 MPLab
6.2 Proteus

Bộ Môn Kỹ Thuật Điện Tử - ĐHBK

References
• Materials
– Microchip, “MPLAB IDE User’s Guide”, Elsevier 
Newnes, 2009 
• Websites
– http://www.microchip.com

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 2

1
8/9/2016

6.1 Embedded Software Development Tools
MPLAB IDE

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 3

MPLAB
• MPLAB® IDE DESKTOP

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 4

2
8/9/2016

How to use
All projects will have these basic steps:
1. Create Project – Tạo dự án
2. Select Device – Chọn thiết bị
3. Select Language Tools – Chọn ngôn ngữ
4. Put Files in Project – Đặt file vào dự án
5. Create Code – Tạo mã chương trình
6. Build Project – Xây dựng dự án
7. Draw simulation schematic – Vẽ mạch mô phỏng
8. Test Code with Simulator – Kiểm tra mã với phần
mềm mô phỏng
Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 5

Step 1. Create Project 

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 6

3
8/9/2016

Step 2. Select Device

PIC16F84
Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 7

Step 3. Select Language Tools

Select CCS C Compiler

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 8

4
8/9/2016

Name your project

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 9

Step 4. Put Files in Project

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 10

5
8/9/2016

Project wizard ‐ Summary
• After pressing the Finish button, review the Project Window on the 
MPLAB IDE desktop

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 11

Step 5. Create Code
• Add source code to your project
#include <16f84.h>
#use delay (clock=4000000)
void main()
{
while(1)
{
output_high(PIN_A0);
delay_ms(100);
output_low(PIN_A0);
delay_ms(100);
}
}

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 12

6
8/9/2016

Add to project

• Once the file is saved 
you can add it to 
your project

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 13

Step 6. Build Project
• Project>Build All

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 14

7
8/9/2016

Step 7. Draw simulation schematic


• Debugger > Select Tool > Proteus VSM

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 15

Step 7. Draw simulation schematic


• Open Proteus 
• Draw schematic
• Save as blinking_LED.dsn

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 16

8
8/9/2016

Step 7. Draw simulation schematic


• Open “Blinking_LED.dsn” in the Proteus VSM MPLAB

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 17

Step 8. Test Code with Simulator
Simulator toolbar

reset
run animate step into step over routine step out of routine

START SIMULATION

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 18

9
8/9/2016

Step 8. Test Code with Simulator
• Select Debugger>Reset>Processor Reset

Code after processor reset


Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 19

Step 8. Test Code with Simulator
• Select Debugger>Step Into to single step to the code at Main.

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 20

10
8/9/2016

Step 8. Test Code with Simulator
• Select View > Watch

Watch – select variable “count”

Watch – reset values

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 21

2. Advanced simulation with Proteus


• Proteus Virtual System Modelling (VSM) combines mixed mode SPICE circuit
simulation, animated components and microprocessor models to facilitate co-
simulation of complete microcontroller based designs.
• It is possible to develop and test such designs before a physical prototype is
constructed.

• Available for PIC, 8051, MSP430, AVR, HC11, ARM7/LPC2000 and Basic
Stamp processors
• See your code interact with simulated hardware in real-time
• Interactive peripheral models for displays, keypads, etc.
• Over 8000 analogue and digital device models
• Extensive single step and debugging facilities including system wide
diagnostics.
• Works with popular compilers and assemblers

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 22

11
8/9/2016

Step 1. Create a new design
• Select New > New Design

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 23

Step 2. Pick devices from library
• Select Library > Pick device

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 24

12
8/9/2016

Step 3. Edit component 
• Double click to the component

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 25

Step 3. Edit component 
• Configure:
– Program file (hex file can be created by MPASM, CCS C or Mikro C tools)
– Clock frequency (MHz)

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 26

13
8/9/2016

Step 4. Draw peripherals
• Add more components: resistor, LED, …
• Draw connections
• Save the design

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 27

Step 5. Run the simulation
• Select Debug > Execute

Run the simulation

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 28

14
8/9/2016

Debug and Emulator 

MPLAB REAL ICE In- MPLAB PICkit 3 for PICkit™ 2 Debug


Circuit Emulator System debugging and Express and the PICkit
programming 2 Starter Kit

PIC18F4XK20 Starter Kit PICDEM PIC18F8722 Starter Kit PIC18F46J50

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 29

Exercise 1
Write program that enables 4 LEDs to be turned on gradually in the following
sequence: D0  D1  D2  D3  D2  D1  D0 … Note that the turning cycle
is 1s.

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 30

15
8/9/2016

Exercise 2
Write the program that allows 2 7-seg led to count gradually from 0 to 9 and then
repeat again. Know that LED 7-SEG 0 is common cathode and LED 7-SEG 1 is
common anode and the counting cycle is 500ms.

Bộ môn Kỹ Thuật Điện Tử - ĐHBK Chapter 6 31

16

You might also like