Unit Iii Esd
Unit Iii Esd
Development
UNIT -III
Mrs.J.Swetha Priyanka
Email:[email protected]
VARDHAMAN COLLEGE OF ENGINEERING
Shamshabad, Hyderabad – 501218, India.
Contents
Reset Circuit
Brown-out Protection Circuit
Oscillator Unit
Real Time Clock
Watchdog Timer
Embedded Firmware Design Approaches and Development
Languages
Reset Circuit
A reset circuit is an essential component in digital systems, including microcontrollers,
microprocessors, and other electronic devices. Its primary purpose is to initialize the
system into a known, stable state when power is applied, ensuring that the device starts
operating correctly from the very beginning.
Key Functions of a Reset Circuit:
System Initialization:
When power is first applied to the system, the reset circuit ensures that all internal
registers, peripherals, and memory are initialized to their default states (often zeros or a
known starting value). This prevents the system from starting with random,
unpredictable states that could lead to malfunction.
Power-On Reset (POR):
• The reset circuit ensures that when the power supply is turned on or when the system is
powered after being off, the device starts from a known state. It typically holds the
system in a reset state for a brief period after the power is applied to allow time for the
system's components to stabilize.
Correct Timing:
• The reset pulse must be of sufficient duration to allow the clock oscillator and other
internal circuits to stabilize. For example, the clock might need time to stabilize after
power is applied, and the reset signal ensures that the system waits for this stabilization
before starting normal operation.
• Fault Recovery:
• In case of a malfunction, software crash, or if the system enters an unknown state, the
reset circuit can force the system back to its initialized state, ensuring recovery without
manual intervention.
• The reset circuit ensures the device operates at a stable voltage during power ON.
• It initializes internal registers and hardware systems to a known state.
• The reset vector typically starts at address 0x0000 but can be relocated for bootloader
support.
• Reset signals can be active high or active low, depending on the processor.
• The reset pulse must be long enough for the clock oscillator to stabilize.
• Reset can be applied through a passive RC circuit or a standard reset IC like MAX810.
• A simple RC (Resistor-Capacitor) network is often used to create the delay required
for a reset pulse. The capacitor charges through the resistor when the system is powered
on, and once the voltage across the capacitor reaches a certain level, the reset is released.
• Some processors have built-in reset circuits and don’t require external components.
• The reset pulse width can be adjusted by changing resistance (R) and capacitance (C).
Brown-out Protection Circuit
• A brown-out protection circuit is a crucial feature in embedded systems and
microcontrollers, designed to ensure that the system remains stable during periods of low
voltage or voltage dips (referred to as "brown-outs"). Brown-out protection helps to prevent
unpredictable behavior or malfunction when the system’s supply voltage falls below a certain
threshold, which could otherwise lead to incorrect operations or data corruption.
Brown-out protection prevents unexpected processor behavior due to low supply voltage.
It is crucial for battery-powered devices to avoid voltage drops below the required threshold.
Voltage drops can cause unpredictable processor behavior and data corruption.
Some processors have built-in brown-out protection, while others require external circuits.
Brown-out protection can be implemented using Zener diodes, transistors, or supervisor ICs.
Zener diodes are used to monitor and protect the system from low voltage conditions (also
known as brown-outs).
Zener diodes are components that exhibit voltage regulation characteristics, making them
useful in situations where a voltage needs to be controlled or limited.
The Zener diode sets the low voltage threshold, and the transistor controls reset activation.
Supervisor ICs like DS1232 from Maxim Dallas provide reliable brown-out protection.
Oscillator Unit
An oscillator unit is an essential component in many electronic systems, including
microcontrollers, microprocessors, and communication devices. It generates a periodic
waveform (usually a sine wave or a square wave) that is used to drive various circuits,
including timing and synchronization systems. The frequency of the oscillator defines the
rate at which the system operates and is critical for the overall functioning of the system.
A microprocessor/microcontroller operates in sync with a clock signal, like a heartbeat in
living beings.
The frequency of the oscillation (measured in Hertz, Hz) determines how quickly the
system operates. For example, a microcontroller might operate at a frequency of 16 MHz,
meaning it performs 16 million cycles per second.
The oscillator unit generates the clock signal required for the processor’s operation.
Some processors have built-in oscillators and need only an external quartz crystal or ceramic
resonator.
Quartz crystals and ceramic resonators function similarly but have physical differences.
Processors without built-in oscillators require external clock sources like quartz crystal
oscillators.
The processor's speed depends on the clock frequency but has a maximum limit for stable
operation.
Higher clock frequencies increase power consumption.
The accuracy of program execution depends on the accuracy of the clock signal.
Clock accuracy is measured in parts per million (ppm).
Microcontroller Microprocessor
C : Capacitor
Y : Resonator
Oscillator
Quartz crystal unit
resonator C C
Oscillator
Y
unit
Watchdog Reset
System clock
Where Cfunction is a function written in ‘C’. The prefi x _ informs the cross compiler that the
parameters to the function are passed through registers. If the function is invoked without
the _ prefix, it is understood that the parameters are passed through fi xed memory
locations.
Up to three arguments are passed in registers (R7–R2).
If arguments exceed three, the rest are stored in memory.
Return values are stored in R7 (char) or (R7, R6) (int).
Use LCALL _Function Name in Assembly to call a C function.
The _ prefix ensures register-based parameter passing; while omitting it uses
memory instead.
This method improves performance by minimizing memory access and making
function calls more efficient.
3.3 Inline Assembly
1. Definition of Inline Assembly
Inline assembly is another technique for inserting target processor/controller specific Assembly
instructions at any location of a source code written in high level language ‘C’.
Inline assembly allows embedding assembly instructions directly within a C program.
This is useful when we need to write processor-specific instructions while still keeping most of the
code in C.
This approach is different from calling an external assembly function; here, the assembly code is
inserted inside the C code itself.
2. Avoiding Function Call Overhead:
This avoids the delay in calling an assembly routine from a ‘C’ code (If the Assembly instructions to
be inserted are put in a subroutine as mentioned in the section mixing assembly with ‘C’)."
Normally, calling an assembly function from C requires a function call, which introduces:
Stack operations (pushing and popping parameters).
Context switching (saving and restoring registers).
Inline assembly avoids this overhead by placing assembly instructions directly inside the C function,
making execution faster.
3. Using Special Keywords for Inline Assembly
• Special keywords are used to indicate the start and end of Assembly instructions.
• Inline assembly requires special keywords to define the start and end of the assembly block inside
a C program.
• These keywords tell the compiler that the enclosed statements should be treated as assembly code
rather than C code.
The keywords are cross-compiler specific. C51 uses the keywords #pragma asm and
#pragma endasm to indicate a block of code written in assembly.
The method for mixing Assembly with C varies across different cross-compilers.
Users should refer to their specific cross-compiler documentation for proper
implementation