Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 15

Microcontroller Development

Environment
CE432 Microprocessor System
Lecture 02

Dareen K. Halim
Universitas Multimedia Nusantara
Target competencies
Sub-CLO 2 Students can describe microcontroller development and
programming environment - C5
How does a microcontroller work?
Think of the definition of “computer” by Von Neumann
• Computer has Processing Unit, Memory, and I/O.
• The Memory stores data, as well as instruction telling what
the computer should do.
• Upon starting, the CPU will fetch the instruction at the first
memory address, execute it, fetch the instruction at the next
address, and so on.

To put it simply, microcontroller works according to the program


(list of instructions) that presents in their memory.
How does a microcontroller work?
Next question – how can we provide the
program into the microcontroller?
• Prepare the program
• Code vs program vs instructions
• C language vs Assembly vs Machine
Instructions?
• Compiler vs Interpreter?
• Send the program to the microcontroller
Preparing program for microcontroller
Code vs program vs instructions
• We will first agree on these loosely-defined terms.
• Computer runs based on program, which is a list of instructions supplied by the
programmer.
• Code  the “thing” that programmers write, containing instructions for the
computer, using programming language.
• The next problem is, the code that programmers write is in a different language from
the one that the computer understands.
• Humans better understand high-level programming language
• Computers understand machine language.
Preparing program for microcontroller
C language vs Assembly vs Machine Language
Easier for More
human “portable”
instructions

Machine-
specific
instructions

Easier for
machine
https://www.cs.mtsu.edu/~xyang/2170
/computerLanguages.html
Preparing program for microcontroller
Compiler vs interpreter
Both are tools for “translating” from code written in high-level programming
language into machine language.
• Compiler  “translates” in a batch (this is the one used in microcontroller)
• The code must be checked first for any syntax error etc.
• Also performs optimization (e.g., smaller code size, faster code speed).
• Interpreter  “translates” per line (possible to use, but very rare in
microcontroller)
• We’ll come back to this after you learn about MicroPython in your lab
activity.
Sending program to the microcontroller
Microcontroller
Personal Computer
Loader
- Accepts the
Software for sending USB Specific program (e.g., per
Compiled port pins byte) sent through
the program
program through serial port ? specific pins
- Put the received
(USB)
What’s program in the
here? ROM

ROM
Sending program to the microcontroller
Microcontroller
Personal Computer
Loader
- Accepts the
Software for sending USB Specific program (e.g., per
Compiled port pins byte) sent through
the program
program through serial port ? specific pins
- Put the received
(USB)
program in the
ROM
1 2 3
How do we What kind What kind ROM
get this? of of
software? hardware?
Sending program to Atmega328p
• Assume we want to send program to Atmega328p as an example.
• Study these links
a. https://www.youtube.com/watch?v=BHryCFw2U30&list=PLtuqBdbsL-DvbB6QAGgo
GBAEsGuXfGFoF&index=1
(skim through video 1-4 in the playlist)
b. https://www.youtube.com/watch?v=tiETAwkxnmw
• After studying the links, can you find the answer to questions (1), (2), and (3) from the
previous slide?
Embedded system development
environment
Host system Target system
Serial comm
Modules

PC Used for Micro-


- ‘FLASH’-ing controller Modules
Dev software


- Debugging
suite
- Testing
Cross-compile
- Interface Modules
(rarely
happens)
Binary
Code
Program

11
Arduino
• What about Arduino?
• What is it? Why is it created?
• How does it work?
• If you program different microcontrollers using Arduino, will you notice
anything different, code/programming-wise?
• Should we use it or not?
Arduino
Arduino is a development environment consisting of both hardware and
software that is aimed to make embedded system development easier.

Hardware Software
• Remember that each microcontroller • Remember the toolchains from the
is different, they have different previous links?
specifications, features.
• All of them are hidden in the
• All of them are hidden behind the Arduino IDE. All users need to
Arduino board. All users need to know is install the Arduino IDE,
know is buy the board and use and all the tools are already
them!
installed!
Then should we use Arduino?
Pros Cons
• It is very easy and quick to get • Hides lot of details of
started. microcontrollers.
• More understandable for non- • Specs, features, toolchains.
technical people. • Makes people think all
• Suitable for simple projects that microcontrollers are the same,
are still within Arduino’s capability. while they are not!
References
• [1] The AVR Microcontroller and Embedded Systems: Using Assembly and
C. M Ali Mazidi et. al.
• [2] Making Embedded Systems. Elecia White.

You might also like