4.6 Serial Interface (USART)
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
Read Data
Copy the files
serial.c
and
serial.h
and use the function
int ser getchar (void)
.
Listing 4.7:
Receive Data
while
( ! ( USARTx
−
>
SR & USART FLAG RXNE) ) ;
// wait u n t i l a char has been
r e c e i v e d
yourCharacter = (USARTx
−
>
DR & 0 x1FF ) ;
// read c h a r a c t e r from t h e b u f f e r
4.6.3 Using Interrupts
Configuration
The configuration is done with the
Settings Wizard
shown in Figure
. The function
void USART2 IRQHandler (void)
is called when an interrupt, configured in the
Settings Wizard
,
occurs. Refer to the example
usartIrq1
for more information.
Figure 4.4:
USART Configuration Wizard (using Interrupts)
4.6.4 Driver
The data are transmitted on the system voltage level
to the converter and there converted to the
RS232 level
. The RS232 interface can then be connected to any PC. For a minimum communica-
tion three wires are required:
•
TxD:
Tranceive Data
•
RxD:
Receive Data
•
GND:
Common Ground
Figure
shows the driver included in the STM32F103RB .
1
System voltage:
+3.3V (=HIGH) and 0V (= LOW)
2
RS232 level:
+12V (=LOW = 0) and -12V (= HIGH = 1)
Lukas Kohler
29