1 Intro
2
Electrocardiogram (
Ecg
) Signals
The Electrocardiogram (
Ecg
)
•
Ecg
: electrical manifestation of heart activity recorded
from the body surface
•
monitoring of heart rate
The
Ecg
signal can be recorded fairly easily with surface
electrodes placed on the limbs and/or the chest, see pages
6
–
16
below.
Josef Goette
2
2009
4 Peripherals
The events generated by the standard timers (TIMx) and the Advanced Control timer (TIM1) can
be internally connected to the ADC start trigger, injection trigger, and DMA trigger respectively,
to allow the application to synchronize A/D conversion and timers.
Listing 4.10:
ADC Init
/
∗
I n i t i a l i z e s t h e Analog/ D i g i t a l c o n v e r t e r
PC1 (ADC Channel10 ) i s used as analog i np ut
∗
/
void
a d c I n i t (
void
)
{
65
RCC
−
>
APB2ENR
|
= RCC APB2ENR ADC1EN ;
// e n a b l e p e r i p h e r a l c l o c k
f o r ADC1
ADC1
−
>
SQR1
= 0 x00000000 ;
// only one c o n v e r s i o n
ADC1
−
>
SMPR2 = 0 x00000028 ;
// s e t sample time channel1
( 5 5 , 5 c y c l e s )
ADC1
−
>
SQR3
= 1 0 ;
// s e t channel10 as 1 s t
c o n v e r s i o n
70
ADC1
−
>
CR1
= 0 x00000100 ;
// use independent mode ,
SCAN mode
ADC1
−
>
CR2
= 0 x000E0003 ;
// data a l i g n r i g h t , c o n t
c o n v e r s i o n
// EXTSEL = SWSTART
// e n a b l e ADC, no e x t e r n a l
T r i g g e r
75
ADC1
−
>
CR2
|
=
0 x00500000 ;
// s t a r t SW c o n v e r s i o n
}
Listing 4.11:
Read ADC Values
/
∗
read a converted value from t h e Analog/ D i g i t a l c o n v e r t e r
∗
/
unsigned char
adc Get (
void
)
{
unsigned s h o r t
v a l ;
80
while
( ! ( ADC1
−
>
SR & ADC SR EOC ) ) ;
// wait t i l l end o f
c o n v e r s i o n
v a l = ADC1
−
>
DR & ADC DR DATA ;
// Get c o n v e r s i o n r e s u l t
v a l = ( v a l
>>
4 ) & 0xFF ;
// S c a l e analog value t o 8
b i t s
85
r e t u r n
( v a l ) ;
}
38
STM32 Cortex-M3 Tutorial