1
Podstawy techniki
mikroprocesorowej
ETEW006
Redukcja mocy
EMC
Niezawodność działania programów
Andrzej Stępień
Katedra Metrologii Elektronicznej i Fotonicznej
Silicon Labs C8051F50x
Supply Voltage 1.8 to 5.25 V
typical operating current: 18 mA @ 50 MHz; 20
µ
A @ 32 kHz
typical stop mode current: 3
µ
A
Digital Peripherals
−
All I/O Ports 5 V tolerant with high sink
current
−
CAN 2.0 Controller – no crystal required
−
LIN 2.0 Controller (Master and Slave
capable); no crystal required
−
Hardware enhanced UART, SMBus™, and
enhanced SPI™ serial ports
Clock Sources
−
Internal 24 MHz with ±0.5% accuracy
for CAN and master LIN operation
−
External oscillator: Crystal, RC, C, or clock (1 or 2 pin modes)
−
switch between clock sources on-the-fly
; useful in power saving modes
Temperature Range: –40 to +125 °C
TI MSP430F2xxx / MSP430F54xx
Low Supply Voltage Range 1.8 V to 3.6 V
Ultralow Power Consumption (MSP430F54xx):
−
Active Mode (AM): 165
µ
A/MHz at 8 MHz
−
Standby Mode (LPM3 RTC Mode): 2.60
µ
A
−
Off Mode (LPM4 RAM Retention): 1.69
µ
A
−
Shutdown Mode (LPM5): 0.1
µ
A
Five Power-Saving Modes
Ultrafast Wake-Up From Standby Mode in Less Than 1
µ
s
(MSP430F2xxx)
Basic Clock Module Configurations
(MSP430F2xxx):
−
Internal Frequencies up to 16 MHz With Four
Calibrated Frequencies to ±1%
−
Internal Very Low Power LF Oscillator
−
32-kHz Crystal
−
External Digital Clock Source
How to
power an
MCU
Power Consumption
static
(P
s
) – in the datasheet:
•
I
CC
•
∆∆∆∆
I
CC
dynamic
power consumption (P
d
) – usually forms the bulk
of power consumption:
•
transient power consumption
(P
t
)
•
capacitive load power consumption
(P
L
)
CMOS Power Consumption and Cpd Calculation.
Texas Instruments, SCAA035B, June 1997
Static Power Consumption
I
CC
– supply current
P
S
= V
CC
∗
I
CC
where: V
CC
= supply voltage
I
CC
= current into a device
(sum of leakage currents)
∆∆∆∆
I
CC
– extra supply current for every input that is at a voltage other
than 0 or 5V (when the input levels are not driven all the way to
the rail, causing the input transistors to not switch off completely)
Dynamic Power Consumption
transient power consumption
(P
t
):
P
T
= C
pd
∗
V
CC
2
∗
f
I
∗
N
SW
where: C
pd
= dynamic power-dissipation capacitance
V
CC
= supply voltage
f
I
= input signal frequency
N
SW
= number of bits switching
capacitive load power consumption
(P
L
):
P
L
= C
L
∗
V
CC
2
∗
f
O
∗
N
SW
(C
L
is the load per output)
where: V
CC
= supply voltage
f
O
= output signal frequency
C
L
= external (load) capacitance
N
SW
= total number of outputs switching
2
Power Consumption With a Single
Output Switching for TI’s ’245
Figure 8. Power Consumption With a Single Output Switching for TI’s ’245
I
C
C
[m
A
]
Frequency [MHz]
Power
Consumption
in Golf
(das Auto)
Figure 4 Reducing the
average current draw
has different impacts
on battery life.
Matt Ruff (Freescale Semiconductor)
Reducing power consumption in
batterypowered applications.
EDN, 2007, may 24, p. 81
Medical Electronics
Steve Kennelly: Reducing Power Consumption in Embedded Medical
Electronics. Medical Electronics Manufacturing, Spring 2007
Small device packages, reduced power consumption
Advanced semiconductors
that
integrate more features on a single
device
have enabled designers to
miniaturize medical devices
and to
extend device lifetimes
by
lowering power consumption
Batteries
are the
principal power
source
in
many low-power
applications
Batteries
that are suitable for
high-current applications
have
lower
capacity
or
greater weight
than a similarly sized high-internal-resistance
battery
MCU
to be able to handle a variety of low-powered designs, it is important that
it
operate
with a
wide range of power supplies
: for instance, when a device
uses
alkaline batteries
,
1.8-V
operation is desirable because the
end voltage
on each
cell is 0.9 V
and the
application typically employs two cells
Power Reduction Methods
in MCU
Some
MCU families
now commercially
available
provide special features for
power management
; these generally involve controlling power consumption
by peripherals, letting the
MCU sleep periodically
, or
manipulating
oscillator start-up
Controlling Power to Peripherals
– a cardinal principle of power
management in portable embedded systems is to enable the
MCU to control
the
power used by both internal and external peripherals
; for example, a
brownout-reset feature is not needed in battery-powered applications. A
designer thus can save power by disabling it
MCU Sleep Modes
– put the
MCU to sleep occasionally
, at times when the
system's demand for the controller's resources is low; then, to perform useful
work, the sleeping MCU is awakened, either through an interrupt or when a set
period on a watchdog timer has expired – longer the MCU can be allowed to
sleep, the lower the average power consumed by the application will be
Power Reduction Methods
Oscillators
Start-up event
occurs
while
the
MCU is idle
(that is, not executing any code):
−
during the start-up period, as the oscillator stabilizes, the MCU is not doing
any work, yet it continues to consume power
−
oscillator start-up time
usually
is not mentioned
in the MCU's data
sheet, because its
duration
will
vary depending on the crystal
,
loading
capacitors
,
system environment
,
oscillator mode
, and so on
Use a two-speed oscillator start-up
:
−
MCU immediately starts to execute code from a fast-starting secondary
oscillator, such as a RC oscillator
−
when the primary oscillator is ready, it is switched into the circuit to replace
the secondary oscillator
−
such a design is critical for applications in which a device cycles from sleep
to waking and back frequently
Power Reduction Methods
Bidirectional I/O pins
designers should be careful about the signals applied to these pins so
that the amount of power consumed can be minimized
if a port
pin
is
unused
, the designer can leave it unconnected but
configured as
an output pin driving to either state,
high
or
low
, or, it can
be
configured
as an
input
with an
external resistor
pulling it to V
DD
(the
supply voltage) or V
SS
(the ground)
when the port pin is
configured
as an
input
, only the pin
input leakage
current
will be drawn through it – current flow would be the same if the
pin were connected directly to V
DD
or V
SS
in this way, the pin can be used later, for either input or output, without
extensive hardware changes
3
Power Reduction Methods
Peripherals
Figure 1. The I/O
pins
of an MCU can be
used to power
the
EEPROM
and the
sensor
in this data-recorder application
Power
Consumption
Matt Ruff (Freescale Semiconductor): Reducing power consumption
in batterypowered applications. EDN, 2007, may 24, p. 82
RUN MODE
EXTERNAL EVENT TRIGGERS RUN MODE,
FAST START-UP WITH 4-MHz-BUS SELF-CLOCK MODE
COMPARATIVE
POWER
CONSUMP
STOP 1
STANDBY POWERDOWN,
TYPICALLY, 20 nA AT 2V
STOP 2
WITH AVERAGE WAIT TIME/
REAL-TIME CLOCK ENABLED
INTERNAL 2-kHz WAKE-UP
OSCILLATOR ON
RAM AND I/O CONTENTS POWERED,
TYPICALLY, 700 nA AT 2V
RUN MODE
AVERAGE WAIT TIME/RTC TRIGGERS RUN MODE
CHECK WHETHER HIGH-SPEED SERVICE IS
NECESSARY;
IF NOT, GO BACK TO STOP 2 WITH AVERAGE WAIT
TIME ENABLED
RUN MODE
HIGH-SPEED SERVICING IS REQUIRED:
INCREASE BUS SPEED TO 20 MHz WITH
INTERNAL CLOCK GENERATOR
COMPLETE TASK, THEN GO BACK TO
STOP 2 WITH AVERAGE WAIT TIME
STOP 1
DEVICE TIMES OUT, ENTER
STANDBY POWERDOWN,
TYPICALLY 20 nA AT 2V
Fig. 2 The power-
consumption profile
for stop and run
modes includes a
periodic wake-up
Active versus Sleep Mode
(AVR MCU) (1/2)
Arne Martin Holberg, Asmund Saetre: Innovative Techniques for Extremely Low
Power Consumption with 8-bit Microcontrollers. White Paper, Atmel Co. 2006
In many applications, the
processor does not run continuously and peripherals
may be idle much of the time
. The overall power consumption can be lowered by
taking advantage of various “sleep” modes available on virtually all processors. The
most common sleep modes are Power Down (PWD), Power Save (PS) and Idle.
In Power Down mode everything is shut down, including the clock source.
In Power
Save mode everything is turned off except a 32 kHz clock running from a crystal
to keep track of time.
Idle mode is a shallow sleep mode where only parts of the
device are shut down but the main parts of the microcontroller are running.
The advantage of having multiple sleep modes is the flexibility it provides to shut down
any part of the microcontroller that is not absolutely necessary to the function at hand.
The amount of power that can be saved depends on the mode being using. For
example with a
1.8V supply voltage
operating at
1 MHz and 25ºC
, Atmel’s
ATmega165P AVR
controller consumes
340
µµµµ
A in Active mode
,
150
µµµµ
A
in
Idle
mode
,
0.65
µµµµ
A in Power Save
mode and a scant
0.1
µµµµ
A in Power Down mode
.
Active versus Sleep Mode
(AVR MCU) (2/2)
A. M. Holberg, A. Saetre: Innovative Techniques for Extremely Low Power Consumption
with 8-bit Microcontrollers. White Paper, Atmel Co. 2006
Time
Sleep I
CC
Active I
CC
Current
consumption
10% Duty Cycle
Average current
Figure 1: Power budget
Low-Power Applications
Principles
Most important factor for
reducing power consumption
is
using
the clock
system with both a
real-time clock function and all interrupts active
(MSP430Xxxx: 32-kHz watch crystal is used for the ACLK and the CPU is
clocked from the DCO (normally off) which has a 6-
µ
s wake-up)
Use interrupts to wake the processor
and control program flow
Peripherals should be switched on only when needed
Use low-power integrated peripheral modules
in place of software driven
functions (MSP320Xxxx: for example Timer_A and Timer_B can automatically
generate PWM and capture external timing, with no CPU resources)
Calculated branching and fast table look-ups
should be used in place of
flag polling and long software calculations
Avoid frequent subroutine and function calls due to overhead
For
longer software routines
,
single-cycle CPU registers
should be used
Power Saving Modes
Active Mode
– CPU is Active and all Modules (Peripherals) are Active
Slow–Down Mode
– slows down all parts of the controller, the CPU and all
peripherals; Slowing down the frequency significantly reduces power
consumption. The slow down mode can be combined with the idle mode
Idle Mode
– CPU is gated off from the oscillator, all peripherals are still
provided with the clock and are able to work; Idle Mode is entered by software
and can be left by an interrupt or reset
Atmel: Idle mode is a shallow
sleep mode
where only parts of the device are
shut down but the main parts of the microcontroller are running
Wait Mode
– CPU operation is stopped, oscillators remains active (Renesas)
Standby Mode
– Low-power Mode 3 in MSP430 (LPM3), disabled: CPU,
MCLK, SMCLK, DCO’s dc-generator is disabled; ACLK remains active
Power Down Mode / Stop Mode / Halt Mode
– (Hardware or Software)
operation of the MCU is completely stopped and the oscillator is turned off;
this mode is used to save the contents of the internal RAM with a very low
standby current
DVS
– Dynamic Voltage Scaling
4
COP8CBR
National Semiconductor
The low speed oscillator is left on in HALT mode, because
the low speed
oscillator draws very little operating current
.
HS Osc off
LS Osc on
HS Osc off
LS Osc on
Idle
Halt
Low
Speed
Mode
32 kHz
HS Osc off
LS Osc on
T0 clked by LS Osc
Idle
HS Osc off
LS Osc on
HS Osc off
LS Osc on
Halt
Halt
HS Osc off
LS Osc on
Idle
Reset
Dual
Clock
Mode
HS Osc on
LS Osc on
T0 clked by LS Osc
HS Osc on
LS Osc off
T0 clked by HS Osc
High
Speed
Mode
MSP430 Low Power Mode
(Texas Instruments)
RST/NMI
NMI Active
WDTIFG=0
POR
PUC
RST/NMI is Reset Pin
WDT is Active
Vcc On
RST/NMI
Reset Active
WDT Active
Time Expired, Overflow
WDTIFG=1
WDT Active
Security Key Violation
All On
Low Power Mode 4
CPU Off, MCLK Off, SMCLK Off
DCO Off, DC Gen Off
ACLK Off
All Off
Low Power Mode 3
CPU Off, MCLK Off, SMCLK Off
DCO Off, DC Gen Off
ACLK On
Icc=1mA
@Vcc=2,2V
Low Power Mode 2
CPU Off, MCLK Off, SMCLK Off
DCO Off,
DC Gen On
ACLK On
Icc=11mA
(@Vcc=2,2V)
Low Power Mode 1
CPU Off, MCLK Off,
SMCLK On
DCO Off,
DC Gen On
ACLK On
Low Power Mode 0
CPU Off, MCLK Off,
SMCLK On
DCO On, DC Gen On
ACLK On
Icc=65mA
@Vcc=2,2V
Icc=225mA
(@Vcc=2,2V)
Active Mode
CPU is Active
Various Modules are Active
Icc=0,1mA
@Vcc=2,2V
P
Cortex-M3
CPU execution is suspended
Peripherals continue running
Main oscillator and all internal clocks except the IRC
are stopped
Flash memory is in standby, ready for immediate use
Same as Deep-Sleep mode except
Flash and IRC are shut down
All clocks including IRC are stopped.
Internal voltage is turned off
Complete system state is lost, only
special registers in the RTC domain are
preserved
Wake up via reset, external pin, or RTC
Alarm
???
One question system designers may ask themselves is:
“
Why do I need one of these things anyway
?”
There are 3 situations that you must consider when answer-ing this
question:
• what would happen to the microcontroller (or other devices in the
system) if there was noise on the
supply voltage as it powers up
?
• what would happen if there is a
glitch
on the power supply while the
system is running
?
• what does the microcontroller do when the
system power is turned
off
?
V
CC
=5V
Low e nd of ope ra ting ra nge
Mic ro co ntro lle r 'lo s es c o ntro l' he re
Othe r compone nts
in s ys te m
may work down to here
Dan ge r
Zone
Glitc h
in power
s upply
t
t
Gmin
M
a nua l
R
es e t
V
IT
RES ET
Output Undefine d
t
d
t
d
t
d
AN686, Microchip
S LVA056A,
Te xas Ins trum e nts
V
IT+
= 4,59V
V
hys
~1,5V
~0,7 .. 1.1V
V
IT-
= 4,55V
>200ns
200ms
Glitch
in
power
supply
Output Undefined
Brown-Out Detection
LPC213x
UM10120. LPC2131/2/4/6/8 User manual.
Philips Semiconductors, Rev. 02 – 25 July 2006
BOD has 2-stage monitoring
of the voltage on the V
DD
pins:
•
if
V
DD
voltage falls
below 2.9 V
, the Brown-Out Detector (BOD)
asserts an interrupt signal to the Vectored Interrupt Controller
(must be enabled for interrupt)
•
if
V
DD
voltage falls
below 2.6 V
, Reset prevents alteration of the
Flash as operation of the various elements of the chip
•
both
the
2.9 V
and
2.6 V
thresholds
include some hysteresis
BOD circuit maintains this reset
down below 1 V, at which point the
Power-On Reset circuitry maintains the overall Reset
BOD wakes up MCU
and continues operation, bring LPC213x out of
Power-Down mode
5
DVS
D
ynamic
V
oltage
S
caling:
• dynamiczne przeł
ą
czanie napi
ęć
zasilaj
ą
cych w układach, które nie
pracuj
ą
z pełn
ą
moc
ą
(np. odtwarzacz MP3, internetowe audio, kamera
cyfrowa itp.)
• obni
ż
enie napi
ę
cia zasilania rdzenia (U
CC
), zmniejszenie cz
ę
stotliwo
ś
ci
taktuj
ą
cej (f
CLK
) w mikroprocesorach, procesorach sygnałowych (DSP)
• pobór energii proporcjonalny do (U
CC
)
2
∗
F
CLK
, zmiana cz
ę
stotliwo
ś
ci
taktuj
ą
cej
• wydłu
ż
enie czasu
ż
ycia baterii o ok. 15-25% przy oszcz
ę
dnym
gospodarowaniu energi
ą
• wła
ś
ciwe zaprojektowanie struktury mikroprocesora, DSP steruj
ą
cej
stabilizatorem napi
ę
cia
Power Management Mode (PMM)
(1/3)
Kevin Self - Microcontrollers Applications
Engineer, Dallas Semiconductor Corporation
PMM1
XTAL/64
PMM2
XTAL/1024
software
Active Mode
Cristal Oscillator XTAL/4
/Ring Oscillator
Idle Mode
(only CPU OFF)
Stop Mode
XTAL OFF
(All OFF)
hardware
Stop Mode
All OFF +
Cristal Ampl. OFF
External Interrupt or RESET
I
CC
Current
XTAL/4
1 2
4
6
8
10 12 14
16 18
20
5
10
15
20
Icc [mA]
Frequency [MHz]
22
24 26
28 30
(active mode
full speed)
25
30
Type of mode:
35
Idle
XTAL/64
(PMM1 with NOP)
XTAL/1024
(PMM2 with NOP)
Stop Mode
(1 mA)
(backward software
compatibility)
DS80C320
(4 clocks - performance 2,5x)
Exit from Stop Mode
Cristal
Oscillator
Power
µ
C operating
µ
C enters
Stop Mode
Ext. Interrupt
Clock starts
Clock
stabile
µ
C enters
Stop Mode
µ
C operating
4 .. 10 ms
Power saved
RC
Oscillator
Cristal
Oscillator
Power
µ
C operating
µ
C enters
Stop Mode
Ext. Interrupt
Clock starts
µ
C enters
Stop Mode
µ
C operating
Power .vs. Clock Frequency
Burst Mode Operation
Energy consumed vs. processor speed for a 500 machine cycle task,
active mode
Clock
Machine
Total
Current
Frequency
Cycle
Time
I
CC
-Time
Period
Product
10 MHz
400 ns
200 ms
12,41 mA
248 mAs
30 MHz
133 ns
66,5 ms
34,66 mA
230 mAs (
–6%
)
Wewnętrzne generatory
MSP430x1xx
LFXT1CLK
- Low/high-frequency oscillator:
• low-frequency 32,768-Hz watch crystals
•standard crystals, resonators
•external clock in the 450k .. 8MHz range
XT2CLK
- Optional high-frequency oscillator:
•standard crystals
•resonators
•external clock in the 450k .. 8MHz range
DCOCLK
- Internal digitally controlled
oscillator (DCO) with RC-type characteristics.
6
Rezonator kwarcowy
(1/2)
L
1
C
1
R
1
C
0
f
S
=
1
2
Π √
L
1
C
1
Układ zast
ę
pczy
rezonatora kwarcowego
bez obudowy i mocowania
Cz
ę
stotliwo
ść
rezonansu
szeregowego:
Cz
ę
stotliwo
ść
rezonansu
równoległego:
f
a
=
1
2
Π
√
1
L
1
C
1
1
L
1
C
0
+
= f
S
√
C
1
C
0
+
1
B. Gniewi
ń
ska, C. Klimek: Rezonatory i generatory kwarcowe. WKiŁ, Warszawa 1980
Reaktancja
X
L
X
C
f
f
S
f
a
Rezonator kwarcowy
(2/3)
L
1
C
1
R
1
C
0
A
B
C
X1
C
X2
C
X
MCU
Cz
ę
stotliwo
ść
rezonansu
równoległego:
f
a
= f
S
√
C
1
C
L
+ C
0
+
1
C
L
= C
X
+
C
X1
C
X2
C
X1
+ C
X2
gdzie:
f
a
- f
S
f
S
< 0,01 .. 0,5 %
HC 49U
HC 49S
HC 49S/SMD
HC 49S
/SMD
TF206
Startup Time
COP8CBR9/COP8CCR9/COP8CDR9. 8-Bit CMOS Flash Microcontroller
with 32k Memory, Virtual EEPROM, 10-Bit A/D and Brownout.
DS101374, April 2002, National Semiconductor
CKI Frequency Startup Time
10 MHz
1 – 10 ms
3.33 MHz
3 – 10 ms
1 MHz
3 – 20 ms
455 kHz
10 – 30 ms
32 kHz
2 – 5 sec (low speed oscillator)
Clay Turner: Use of the TMS320C5x Internal Oscillator With External Crystals or
Ceramic Resonators. SPRA054, October 1995, Texas Instruments
„
Startup time
is dependent on the external components used, but
generally requires at last
100 ms
after power-up for the oscillator to
stabilize. For this reason, a
reset delay
of
150-200 ms
is recommended
following power-up.”
Crystal Oscillator Start-Up
Oscillator Start-Up (4.608 MHz Crystal
from Standard Crystal Corp.)
V
CC
V
CC
X2
X2
C
X1,2
= 30 pF
C
X1,2
= 50 pF
T
S
, ms
TOM WILLIAMSON: Oscillators for
Microcontrollers
APPLICATION NOTE AP-155, June 1983, Intel Corp.
Parametry rezonatorów kwarcowych
Nominal frequency range
f
32.768 kHz
Temperature
storage
T
STG
−
55
°
C to +125
°
C
range
operating
T
OPR
−
40
°
C to +85
°
C
Maximum drive level
GL
1,0
µ
W
MAX
Soldering condition
T
SOL
Twice at under 260
°
C within 10 s
or under 230
°
C within 3 min.
Frequency tolerance (standard)
∆
f/f
±
20ppm or
±
50ppm
(Ta=25
°
C, DL=0.1
µ
W)
Peak temperature (frequency)
θ
T
25
°
C
±
5
°
C
Temperature coefficient (frequency)
α
−
0.04ppm/
°
C
MAX
Load capacitance
C
L
6pF
Series resistance
R
1
50k
Ω
MAX
Motional capacitance
C
1
1.8pF
MAX
Shunt capacitance
C
0
0.9pF
MAX
Insulation resistance
IR
500M
Ω
MIN
Aging
fa
±
3ppm/Y
MAX
(Ta=25
°
C
±
3
°
C, first year)
Shock resistance
S.R.
±
5ppm
MAX
(test with: 3000G x 1/2 sine wave x 3 directions)
Crystal Specifications
Crystal Considerations with
Dallas Real Time Clocks. APP58,
Dallas Semiconductor, 1995
Nominal Freque ncy
Pa ra meter
Load Ca pa cita nce
Symbol
Min
Typ
Ma x
Units
Te mpe rature Turnove r Point
Para bolic Curva ture Cons ta nt
Qua lity Fa ctor
Series Res ista nce
Shunt Capa citance
Capacita nce Ra tio
Drive Le ve l
32,768
kHz
6
pF
25
30
20
C
ppm/ C
0,042
Q
70.000
40.000
45
k
Ω
pF
1,1
1,8
430
600
1
µ
W
C
L
F
0
T
0
k
R1
C
0
D
L
C / C
0
1
o
o
Daiwa DS-26S Crystal
Specifications
0
-20
-40
-80
-60
-100
-120
-160
-140
-180
-40
-30
-20
-10
0
10
20
30
40
50
60
70
80
Temperature [
°
C]
Delta
frequency
[ppm]
DS1485
(25
°
C):
±
30 seconds / month (C
L
= 6 pF)
±
4 minutes / month (C
L
= 12 pF)
7
PCB - Crystal Oscillator
Peter Mariutti: Crystal Oscillator of the C500 and C166 Microcontroller Families.
ApNote AP242005, Infineon Technologies, 1999
Quartz Crystals
&
Ceramic Resonators
Peter Mariutti: Ceramic Resonator Oscillators and the C500 and C166
Microcontroller Families. ApNote AP242401, Infineon Technologies, 1999
Principal technical Differences between Quartz Crystals and Ceramic
Resonators
Ceramic Resonator
Quartz Crystal
Price Factor (depends on quality)
1
2
Mechanical Shock Resistance
very good
good
Integrated Caps available
yes
no
Aging (for 10 years at room temperature) ± 3000 ppm
± 10 ppm
Initial Frequency Tolerance
± 2000 ... 5000 ppm
± 20 ppm
Temperature Characteristics
± 20 ... 50 ppm/°C
± 0. 5 ppm/°C
Load Capacitance Characteristics
± 100 ... 350 ppm/pF
± 15 ppm/pF
Oscillation Rise Time
0.01 ... 0.5 msec
1 ... 10 msec
Quality Factor (Qm)
100 ... 5 000
10 000 ... 500 000
Internal RC Oscillator
AVR051: Set-up and Use the External RC Oscillator.
Application Note, Atmel Corporation 2002
f
≈
1
3 R C
Short start-up time of RC oscillator:
max. 4 µs + 10 clock cycles
Frequency and power consumption for C=22pF
(1)
/
C=100pF
(2)
, simulated values
Resistor Value (k
Ω
) Frequency (MHz) Typical Consumption Current (mA)
1.2
11.9 /
4.54
1.0 /
0.57
2.2
7.36 /
2.32
1.0 /
0.18
3.9
4.40 /
1,41
0.57 /
0.18
8.2
1.98
0.18
18.0
0.99
0.18
(1)
C = 22 pF, and 12 pF stray capacitance (package, pad, pin, and PCB)
(2)
C = 100 pF, and 12 pF stray capacitance (package, pad, pin, and PCB), 5V
ATmega8(L)
Internal Calibrated RC
Oscillator Frequency vs.
Operating Voltage
(the devices are calibrated to
8 MHz at V
CC
= 5V, T=25
°
C)
Internal Calibrated RC
Oscillator Frequency vs.
Temperature
(the devices are calibrated
to 8 MHz at V
CC
= 5V,
T=25
°
C)
20
°°°°
C
5V
3V
LPC247x
Internal RC osc. temperature characteristics
Ceramic Resonator Start-Up
Oscillator Start-Up
(3.58 MHz Ceramic Resonator
from NTK Technical Ceramics)
T
S
,
µµµµ
s
TOM WILLIAMSON: Oscillators for Microcontrollers
APPLICATION NOTE AP-155, June 1983, Intel Corp.
C
X1,2
= 50 pF
C
X1,2
= 150 pF
X2
X2
8
External Memory
External
1 2
4
6
8
10
12 14 16 18 20
10
20
40
60
80
Icc [mA]
Internal
Type of memory:
Frequency [MHz]
22 24 26
28
30
DS87C520,
74AC573,
27C256 (70ns)
DS87C520
(16KB of EPROM)
Internal or External
Program Memor
External
1 2
4
6
8 10 12 14 16 18 20
5
10
20
30
40
Icc [mA]
Internal
Type of memory:
Frequency [MHz]
22 24 26 28 30
DS87C520,
74AC573,
DS2064
(8Kx8 Static RAM)
DS87C520
(1 KB internal MOVX data memory)
50
Internal or External
Data Memory
Zakłócenia elektromagnetyczne
(1/2)
oddziaływanie zewn
ę
trznego pola elektromagnetycznego:
• przepi
ę
cia indukowane w zewn
ę
trznych doprowadzeniach,
ś
cie
ż
kach drukowanych
• przepi
ę
cia indukowane w wewn
ę
trznych doprowadzeniach
(indukcyjno
ś
ci i pojemno
ś
ci poł
ą
cze
ń
struktury wewn
ę
trznej z
wyprowadzeniami)
emisja własnego pola elektromagnetycznego:
• bł
ę
dne wykonanie poł
ą
cze
ń
dla du
ż
ych pr
ą
dów obci
ąż
e
ń
• nadmiarowe, bezzasadne generowanie dodatkowych sygnałów
wyładowania elektrostatyczne
Zakłócenia elektromagnetyczne
(2/2)
wła
ś
ciwa konfiguracja systemu
• eliminacja dodatkowych układów towarzysz
ą
cych, np. 8-bitowy
bufor linii adresowych w C51
• eliminacja wszystkich, zb
ę
dnych zewn
ę
trznych układów, np.
zewn
ę
trznych pami
ę
ci w C51
• test sumy kontrolnej (CRC) całej pami
ę
ci kodu
• stosowanie pami
ę
ci kodu programu programowanej mask
ą
• wył
ą
czenie wszystkich nie u
ż
ywanych sygnałów steruj
ą
cych, np.
ALE, RD# i WR# w C51
wła
ś
ciwy dobór mikrokontrolera, mechanizmów kontroluj
ą
cych działanie
programu:
• programowe
• sprz
ę
towe
szereg tryboelektryczny - zestawienie materiałów pod wzgl
ę
dem biegunowo
ś
ci
i wielko
ś
ci ładunku wytwarzanego podczas zetkni
ę
cia i rozdzielenia dwóch
materiałów:
L. Baranowski: Systemy kontroli ESD.
Elektronik, kwiecie
ń
2003
ludzka r
ę
ka:
+
• azbest
• futro królika
• włókno octanowe
• szkło
• mika
• ludzki włos
• nylon
• wełna
• ołów
• jedwab
• aluminium
• papier
stal
drewno
bursztyn
guma utwardzona
nikiel, mied
ź
srebro, mosi
ą
dz
złoto, platyna
jedwab octanowy
celuloid
poliester
akryl
polietylen
polipropylen
silikon
teflon
—
bawełna
Wyładowania elektrostatyczne
(1/2)
czynno
ś
ci i odpowiadaj
ą
ce im przykładowe ładunki w Voltach dla ró
ż
nych
poziomów wilgotno
ś
ci:
czynno
ś
ci
chodzenie po dywanie
chodzenie po podło
ż
u wykonanym z materiałów
syntetycznych
poruszanie si
ę
w obr
ę
bie stanowiska roboczego
wyci
ą
ganie układu scalonego z szyny z tworzywa
sztucznego
wyci
ą
ganie układu scalonego z podstawki
wyci
ą
ganie układu scalonego ze styropianu
wyci
ą
ganie płytki elektronicznej z opakowania z
tworzywa sztucznego
zapakowanie płytki elektronicznej w wytłoczk
ę
z
tworzywa sztucznego
10%
35.000
12.000
6.000
2.000
11.500
14.500
26.000
21.000
40%
15.000
5.000
800
700
4.000
5.000
20.000
11.000
55%
7.500
3.000
400
400
2.000
3.500
7.000
5.500
wilgotno
ść
wzgl
ę
dna
Wyładowania elektrostatyczne
(2/2)
Safety Device
A
microcontroller
, or any programmed machine,
is not an electronic
brain
, in spite of how it was first introduced. Rather, it is an automaton
that has a precise job to perform, taking into account events and
conditions that are considered when the program is written.
However,
not all events can be taken into account
; some
occurrences are even neglected, since they are supposed to never
happen. Rightly or wrongly, the code is thus made shorter.
If, however, either because the programmer made a mistake or because
a hardware failure produced an unforeseen event, the
program may be
fooled
and the
whole application may fail to work
or even produce
harmful actions.
ST7. 8-BIT MCU FAMILY USER GUIDE.
STMicroelectronics, July 2002
9
Safety Programming
Write better code
. Check what happens if a neglected condition arises.
Lead the execution to a recovery routine in such an event. In short, take
all precautions to prevent the program from crashing in any event. This
is actually a requirement, not a choice. But still, things may happen that
are totally out of the control of the author of the program. For example,
an electromagnetic aggression or a power brownout to the product that
is controlled by the microcontroller. Then, the proper working of the
microcontroller may not be guaranteed and the system fails. This is
when the watchdog can play its part.
Methods of
detecting processor failure
by electronic means are
virtually non-existant. A popular method relies on a timer that acts like
an alarm-clock. The clock is wound up for a certain delay. If it has not
been rewound before the expiration of this delay, the clock perform a
hardware reset to the microcontroller.
WATCHDOG
It is up to the program to
periodically rewind the clock
(the watchdog
timer) to indicate that it is still alive. Actually, it is not a full protection,
since some parts of the program may crash while the part that has been
elected to rewind the timer still functions. It is up to the wise programmer
to find the program segment that is very unlikely to still work while some
other part has crashed. Well implemented, this method gives rather
good results. Of course, resetting the program is not a good way to
recover from a fault, since the crash may have sent commands to the
external world that are themselves faulty. The watchdog timer is actually
a last ditch safety device, somewhat like a lifeboat in a shipwreck.
It has the
ability to induce a full reset of the MCU
if its counter counts
down to zero prior to being reset by the software.
This feature is especially
useful in noisy applications
.
The watchdog timer is a
safety device
rather than a peripheral
Watchdog
w C320/530 Dallas/Maxim (1/3)
główny
generator
/2
17
/2
20
/2
23
/2
26
/2
9
WTRF
kasowanie programowe
ustaw
wewn
ę
trzne
zerowanie
WTRF
kasowanie programowe
ustaw
przerwanie
(adr=63h)
EWT
EA
EWDI
SETB RWT
strat/
/od
ś
wie
ż
anie
Watchdog
WD1,WD0
SMOD1
POR
EPF1
PF1
WDIF
WTRF
EWT
RWT
WDCON (0D8h)
WD1
WD0
T2M
T1M
T0M
MD2
MD1
MD0
CKCON (8Eh)
Timed Access Register: 0AAh, 55h, POR/WDIF/EWT/RWT
TA (0C7h)
Watchdog
w C320/530 Dallas/Maxim (2/3)
Okres wewn
ę
trznych zerowa
ń
przez licznik Watchdoga w
µ
s:
dzielnik
wst
ę
pny
@1,832 MHz
@11,059 MHz
@12 MHz
@33 MHz
2
17
+ 512
71.825
11.898
10.965
3.987
2
20
+ 512
572.646
94.863
87.424
31.791
2
23
+ 512
4.579.214
758.579
699.093
245.216
2
26
+ 512
36.631.755
6.068.304
5.592.448
2.033.617
główny
generator
/2
17
/2
20
/2
23
/2
26
/2
9
WTRF
kasowanie programowe
ustaw
wewn
ę
trzne
zerowanie
WTRF
kasowanie programowe
ustaw
przerwanie
(adr=63h)
EWT
EA
EWDI
SETB RWT
strat/
/od
ś
wie
ż
anie
Watchdog
WD1,WD0
Watchdog
w C320/530 Dallas/Maxim (3/3)
Uruchomienie Watchdoga:
CK_CON EQU
1000 0000b ; 2
23
stopie
ń
podziału dzielnika wst
ę
pnego
TA_AA
EQU
0AAh
; dost
ę
p do bitów w rejestrze WDCON
TA_55
EQU
55h
; chronionych zapisem czasowym
Reset_WD:
ORL
CKCON, #CK_CON
; programowanie stopnia
; podziału dzielnika
MOV
TA, #TA_AA
; start Watchdoga
MOV
TA, #TA_55
SETB RWT
MOV
TA, #TA_AA
; odblokowanie wewn
ę
trznego zerowania
MOV
TA, #TA_55
; przez Watchdog
SETB EWT
o
k
n
a
c
z
a
s
o
w
e
Watchdog - MSP430
Write to WDTCTL
< > 5Ah
= 5Ah
CNTCL
Restart Watchdog at 0000
ACLK
(32768 Hz)
MCLK
SSEL
0
1
EN
Clear
CLK
2
6
2
9
2
13
2
15
16-Bit Counter
HOLD
11 10
01 00
IS1,IS0
Set
WDTIFG
POR
IRQA
Timer Mode
Reset
0
1
GIE
General Interrupt
Flag
Interrupt
Timer Mode
(0FFF4h)
priority 10
W
a
tc
h
d
o
g
M
o
d
e
Password
Watchdog Interrupt Enable Flag
WDTIE
T
M
SEL
PUC
(Watchdog
Mode
(0FFFEh)
priority 15
(highest)
HOLD
NMIES
NMI
TMSEL CNTCL
SSEL
IS1
IS0
WDTCTL
(120h)
read access = 69h
write access = 5Ah