You are on page 1of 5

LECTURE NOTES 3 – ADDITIONAL SYSTEM COMPONENTS

RESET CIRCUIT BROWN-OUT PROTECTION CIRCUIT


• Essential for the proper functioning of processors / • Prevents the processor / controller from unexpected
controllers of embedded system program execution behavior when the supply
• Ensures that the device is not operating at a voltage voltage to the processor controller falls below a
level where the device is not guaranteed to operate specified votlage.
• Reset signal can be either active HIGH (processor • Essential for battery powered devices since there
undergoes reset when the reset pin of the are greater chances for the battery voltage to drop
processor is at logic HIGH) or active LOW below required threshold
(processor undergoes reset when the reset pin of
the processor is at logic LOW)
• Reset signal to the processor can be applied at
power ON through an external passive reset circuit
comprising a capacitor and resistor.

Brown-out protection circuit with


Active LOW output
• At 𝑡 = ∞, 𝑉𝑐 = 𝑉𝐶𝐶 and 𝐼𝑐 = 0
• Initially, Reset circuit shown in the figure below is at
• Transistor (Q) conducts always when the supply
logic LOW and logic HIGH respectively.
voltage VCC is greater than that of the sum of
VBE and VZ
• Transistor (Q) stops conducting when the supply
voltage VCC falls below the sum of VBE and VZ
• Select the Zener diode with required voltage for
setting the low threshold value for VCC.

• By toggle and release of push button, the circuit will


be reset, the system will be reset to logic HIGH and
logic LOW respectively. Capacitor will re-initialize
charging.
• Assuming that supply voltage falls from 20V to 10V,
at below threshold, base-emitter of transistor is
open, the circuit became off-state
• By setting Zener diode with lower threshold voltage,
even the supply voltage falls down to 10V, the
circuit continues to run at lower voltage.

OSCILLATOR CIRCUIT
• A microprocessor / microcontroller is a digital
device made up of digital combinational and
sequential circuits.
• The instruction execution of a microprocessor /
controller occurs in sync with a clock signal.
• It is analogous to the heartbeat for the generation of
the beat whereas the oscillator unit is responsible
for generating precise clock for the processor.

Prepared by: Engr. Rhodonelle S. Duatin


Department of Computer, Electronics and Electrical Engineering
LECTURE NOTES 3 – ADDITIONAL SYSTEM COMPONENTS

• Certain processor / controllers integrate a built-in


oscillator unit and simply require external ceramic
resonator / quartz crystal for producing necessary
clock signal.

• Contains microchip for holding the time and date


related information and backup battery cell for
functioning in the absence of power

WATCHDOG TIMER
• In desktop window system, if user feel application is
behaving in abnormal way or if the system hangs
up, ‘Ctrl+Alt+Del’ take control of the situation.
• In embedded system, watch dog monitor the
firmware execution and reset the system
processor/microcontroller when the program
• Initial condition, Input = LOW(0V), Output = execution hangs up.
HIGH(5V). Current flow from inverter output and • Watch dog is a hardware time for monitoring the
distributed to 1M-ohm and 270-ohm resistor. firmware execution
Current flowing through 270ohm resistor, applied to
crystal, and create positive pulse.
• Since output has higher potential, current flow from
higher potential (5V) and applied to the input.
• Through inverter, output set to LOW.

• Depending on the internal implementation, the


watchdog timer increments or decrements a free
running counter with each clock pulse and
generates a reset signal to reset the processor if the
count reaches zero for a down counting watchdog,
or the highest count value for an upcounting
watchdog.
• If the watchdog counter is in the enabled state, the
• Capacitor are load capacitors with value from 10pF firmware can write a zero (for upcounting watchdog
to 30pF. Crystal can form frequency 1 – 20 MHz. implementation) to it before starting the execution
• Quartz crystal is of a piece of code (subroutine or portion of code
• Two load capacitors serve to load the crystal and which is susceptible to execution hang up) and the
stabilize oscillations. Total capacitance should watchdog will start counting.
match the value specified by the crystal oscillator. • If the firmware execution doesn't complete due to
• If load capacitors are different, it will not oscillate at malfunctioning, within the time required by the
specified nominal frequency rather it will be “pulled” watchdog to reach the maximum count, the counter
to a slightly different frequency. will generate a reset pulse and this will reset the
processor (if it is connected to the reset line of the
REAL – TIME CLOCK (RTC) processor). If the firmware execution completes
• System component responsible for keeping track of before the expiration of the watchdog timer you can
time reset the count by writing a 0 (for an upcounting
• Holds information like current time (in hours, watchdog timer) to the watchdog timer register.
minutes, and seconds) in 12 hour / 23 hour format,
date, month, year, day of the week, etc. VARIOUS APPROACHES IN EMBEDDED
• Supplies timing reference to the system FIRMWARE DESIGN
• Intended to function even in the absence of power The firmware design approaches for embedded product
with the help of CR2032 battery is purely dependent on the complexity of the functions
to be performed, the speed of orientation required, etc.

Prepared by: Engr. Rhodonelle S. Duatin


Department of Computer, Electronics and Electrical Engineering
LECTURE NOTES 3 – ADDITIONAL SYSTEM COMPONENTS

Two basic approaches are used for Embedded firmware val = map(val, 0, 1023, 0, 180);
design: myservo.write(val);
delay(15);
1. The Super Loop Based Approach
}
2. The Embedded Operating System Based
Approach
Code Sample 3:
int RELAY1 = A0;
The Superloop Based Approach int RELAY2 = A1;
• Adopted for applications that are not time critical int LED1 = 13;
and where the response time is not so important int LED2 = 12;
(embedded systems where missing deadlines are int delayValue = 1000;
acceptable)
void setup() {
• Similar to conventional procedural programming
pinMode(RELAY1, OUTPUT);
where the code is executed task by task. pinMode(LED1, OUTPUT);
• Task listed at the top of the program code is pinMode(RELAY2, OUTPUT);
executed first and tasks just below the top are pinMode(LED2, OUTPUT);
executed after completing the first task.
• In multiple tasks, each task is executed in serial in digitalWrite(RELAY1, HIGH);
this approach. digitalWrite(RELAY2, HIGH);

digitalWrite(LED1, HIGH);
Firmware Execution Flow: digitalWrite(LED2, HIGH);
1. Configure the common parameters and perform Serial.begin(9600);
initialization for various hardware components, }
memory, registers, etc.
2. Start the first task and execute it void loop() {
3. Execute the second task
4. Execute the next task digitalWrite(RELAY1, LOW);
digitalWrite(LED1, HIGH);
5. : Serial.println("RELAY1 ON");
6. : delay(delayValue);
7. Execute the last defined task
8. Jump back to the first task and follow the same flow digitalWrite(RELAY1, HIGH);
digitalWrite(LED1, LOW);
• The order in which the tasks to be executed are Serial.println("RELAY1 OFF");
fixed, and the operation is an infinite loop based
digitalWrite(RELAY2, LOW);
approach
digitalWrite(LED2, HIGH);
Serial.println("RELAY2 ON");
Code Sample 1: delay(delayValue);
float temp;
int tempPin = 0; digitalWrite(RELAY2, HIGH);
digitalWrite(LED2, LOW);
void setup() { Serial.println("RELAY2 OFF");
Serial.begin(9600); }
}

void loop() { Embedded Operating System (OS) Based Approach


temp = analogRead(tempPin); • Operating system which can be either general-
temp = temp * 0.48828125; purpose OS (GPOS) or real-time OS (RTOS) based
Serial.print("TEMPERATURE = "); design
Serial.print(temp); • Example programmable device with Embedded
Serial.print("*C"); Operating System used in embedded product are
Serial.println();
delay(1000); microcomputers such as Raspberry Pi, Banana Pi,
} Orange Pi, etc.
• Most of the processors implement watchdog as a
Code Sample 2: built-in component and provides status register to
#include <Servo.h> control watchdog timer.
Servo myservo;
int potpin = 0; EMBEDDED FIRMWARE DEVELOPMENT
int val; LANGUAGES
Programmer can use either a
void setup() {
1. Target processor controller specific language
myservo.attach(9);
} (generally known as Assembly Language or
Low Level Language)
void loop() {
val = analogRead(potpin);

Prepared by: Engr. Rhodonelle S. Duatin


Department of Computer, Electronics and Electrical Engineering
LECTURE NOTES 3 – ADDITIONAL SYSTEM COMPONENTS

2. Target processor controller independent Assembly Language Instruction Sample 1:


language (like C, C++, JAVA, etc. commonly MOV A, #15
known as High Level Language) • MOV A is the opcode, 15 is the operand (single
3. Combination of Assembly and High-level operand)
language. • The instruction mnemonic moves decimal value of
15 to the Accumulator Register (ALE) of 8051
Assembly Language Based Development microcontroller
• Assembly language is the human readable notation
of machine language whereas machine language is
a processor understandable language
• Processors deals only with binaries 0’s and 1’s
• Machine language is a binary representation and it
consists of 1s and 0s.
• Machine language is most readable by using
specific symbols called ‘mnemonics’

Advantage of Assembly Language Development


1. Efficient Code Memory and Data Memory Usage
(Memory Optimization). Since the developer is
well-versed with target processor architecture and
memory organization, optimized code can be
written for performing operations.
2. High Performance. Optimize code not only
• Assembly language programming is the task of
improves the code memory usage but also
writing processor specific machine code in
improves the total system performance.
mnemonic form, converting the mnemonics into
3. Low Level Hardware Access. Most of the code for
actual processor instructions and associated data
low level programming like accessing external
using an assembler
device specific registers from the operating system.
4. Code Reverse Engineering. Reverse engineering
is the process of understanding the technology
behind a product by extracting the information from
a finished product.

Drawbacks of Assembly Language Development


1. High Development Time. Much harder to program
than high level languages, developer must pay
attention to more details and must have thorough
knowledge of the architecture / memory
organization.
2. Developer Dependency. No common written rule
for developing assembly language – based
applications, programming approach varies from
• The general format of an assembly language developer to developer. Developer has freedom to
instruction is an Opcode followed by operands. The choose different memory location and registers.
Opcode tells the processor/controller what to do 3. Non – Portable. Target applications written in
and the Operands provide the data and information assembly instructions are valid only for that
required to perform the action specified by the particular family of processors (e.g. Intel x86 family
opcode. of processors) and cannot be reused for another
target processors (AMD64 family processors)

High Level Language Based Development


• Most commonly used high – level language for
embedded firmware application development:
o Python. Widely used in web development,
data science, machine learning, scientific
computing, etc.

Prepared by: Engr. Rhodonelle S. Duatin


Department of Computer, Electronics and Electrical Engineering
LECTURE NOTES 3 – ADDITIONAL SYSTEM COMPONENTS

o Java. Known for its “write once, run 3. The investment required is high compared to
anywhere”, commonly used for enterprise Assembly Language based firmware development
application, android app development, and tools.
server-side programming
o C#. Widely used for window applications, Integrating Activity 3
game development, and web development Using https://www.falstad.com/circuit/, simulate the
o C / C++. Used for system programming, reset circuit, brown-out circuit, and oscillator circuit. Add
game development, embedded systems, last 2 digit of student number on the decimal places of
and high-performance applications all capacitors and resistors in the circuit (e.g. 1.36k,
o SQL. Standard language for managing and 10.36pF, 270.36k). Analyze and discuss the observed
querying relational databases. output from the provided circuit. Use the outline below.
o MATLAB. Used in scientific and
engineering fields for numerical computing, I. Reset Circuit
data analysis, and simulation a. Active High (Initial and Toggle State)
• Conversion of source file written in high level b. Active Low (Initial and Toggle State)
language to object file is done by cross-compiler, II. Brown – out Circuit
where as in assembly language based a. VCC is below Zener Threshold Voltage
development, it is carried out by an assembler. b. VCC is above Zener Threshold Voltage
III. Oscillator Circuit
a. No – load capacitors
b. Loaded parallel capacitors

Assembler for specific computer architecture

Cross – Compiler for executable application for


embedded system

Advantage of High – Level Language Based


Development
1. Reduced Development Time. Developer requires
less or little knowledge on the internal hardware
details and architecture of the target processor /
controller e.g. Arduino and Raspberry Pi has
already dedicated IDE or operating system.
2. Developer Independency. Universal and program
written in the high – level language can be easily
understand by second person knowing the syntax
of the language.
3. Portability. Target applications are converted to
target processor / controller understandable format
by a cross compiler.

Limitations of High – Level Language Based


Development
1. The time required to execute a task also increases
with the number of instructions.
2. High – level language-based Code may not be
efficient in accessing low level hardware where
hardware access timing is critical order of nano or
micro seconds.
Prepared by: Engr. Rhodonelle S. Duatin
Department of Computer, Electronics and Electrical Engineering

You might also like