NMJ21304
-MICROCONTROLLER AND INTERFACES-
BIOMEDICAL ELECTRONIC ENGINEERING PROGRAM
YEAR 2, SEMESTER 2
© Anas Mohd Noor, 2023.
All rights reserved. No part of this document may be reproduced or
transmitted in any forms by any means, electronic, mechanical, or
otherwise, whether now or hereafter devised, including photocopying,
recording, or by any information storage and retrieval system without
express written prior permission from the author
CHAPTER 2: PROGRAMMING LANGUAGE
2.1 Introduction
2.2 Programming Language for Embedded Systems
2.3 Graphical Programming
2.4 Programming Language Selection for An Embedded System
2.5 Programming in Integrated Development Environment (IDE)
2.6 Library
2.1 Introduction
A programming language is a way for humans to communicate with computers. Just as we use natural languages
such as English, Malay, Tamil, or Mandarin to communicate with each other, we use programming languages to
give the computer a set of instructions to follow.
Hi Alexa! Hi Boss!
Natural languages Programming Language
2.2 Programming Language for Embedded Systems
Example of Programming language (syntax) uses in embedded systems / microcontrollers / computers
i. Assembly Assembly Example Code
ii. Fotran main
iii. Pascal movlw 0x02 ;move the value 2 into the working register
addlw 0x03 ;add the value 3 to the working register
iv. Cobol movwf result ;store the result in the result variable
v. C
vi. C++ ;End of main program
end
vii. Phyton
viii. HDL
ix. VHDL
x. JAVA C++ Example Code
xi. >> hundreds languages void setup() {
Serial.begin(9600); //initialize the serial monitor
}
void loop() {
int num1 = 2; //set num1 to 2
int num2 = 3; //set num2 to 3
int sum = num1 + num2; //add num1 and num2 and store the result in sum
Serial.println(sum); //print the sum to the serial monitor
delay(1000); //wait for 1 second before repeating the loop
}
2.3 Graphical / Block Programming
Graphical or visual programming refers to programming using graphical symbols, blocks, or icons instead of text-based code to
create software applications. It provides a visual interface for creating, editing, and executing code by connecting blocks that
represent functions, commands, and data structures
Labview
Here is a list of graphical / block based programming languages:
LabVIEW
Simulink
Blockly
Scratch
NoteRED
Tinkercad
Code.org
MakeCode
Snap!
BlocklyProp Simulink
Node-RED
>>Hundreds of diagram/block based programming code
2.4 Programming Language Selection for Embedded System
The selection of a programming language for an embedded system can have a significant impact on the overall performance
and functionality of the system. When choosing a programming language for an embedded system, there are several factors
to consider, including
Resource constraints: This important because many embedded systems have limited processing power, memory, and
storage
Hardware support: This is important for many embedded systems, which require precise control over hardware resources
Development tools: The availability of development tools and resources, such as compilers, debuggers, and libraries, is an
important consideration when selecting a programming language for an embedded system
Code portability: The programming language should be portable and should be able to run on different platforms without
modification.
Real-time performance: The programming language should provide real-time performance and should be able to handle
tasks with strict timing requirements.
2.5 Programming On Integrated Development Environment (IDE)
An Integrated Development Environment (IDE) is a software application that provides a comprehensive set of tools for
software development. It typically includes a code editor, a debugger, and a variety of tools for building and testing
applications. IDEs are designed to make it easier for developers to write, debug, and deploy code.
2.6 Library
A library is essentially a collection of code that has already been written and tested by someone else. This code can be reused
in multiple programs, so you don't have to write it yourself every time you need to use it. For example, there might be a
library for working with dates and times, or a library for handling image processing. These libraries provide you with functions
that you can use to perform common tasks
Library code1 Library code2 Library code3
This chapter on the introduction to a programming language covers several subtopics.
In section 2.1, the chapter introduces the concept of programming languages and explains their role in computer
programming.
Section 2.2 discusses programming languages for embedded systems, which are computer systems designed to perform
specific tasks and are often found in devices such as household appliances, medical equipment, and automobiles.
Section 2.3 explores graphical programming, which is a programming paradigm that uses graphical elements such as
icons and flowcharts to represent program logic.
Section 2.4 provides guidance on selecting a programming language for an embedded system, considering factors such
as the system's hardware, software requirements, and developer expertise.
Section 2.5 covers programming in an Integrated Development Environment (IDE), which is a software application that
provides developers with tools for writing, testing, and debugging code.
Finally, section 2.6 explains the concept of libraries, which are collections of pre-written code that can be used to
simplify programming tasks and improve code quality.