4.6 Serial Interface (USART)
2
Electrocardiogram (Ecg) Signals
The serial interface is used to communicate with other devices. Nowadays it is often used as
debug interface to send information to a host like a PC. UARTs are commonly used in conjunction
with other communication standards such as EIA RS-232.
sends periodically the character "*" with 9600Baud to its host.
usart1
The Electrocardiogram (Ecg)
sends periodically the ASCII characters with 9600Baud to its host.
usart2
• Ecg: electrical manifestation of heart activity recorded
polls the incoming data and sends them back to its sender (9600Baud)
usart3
from the body surface
sends periodically the string "Hello World" with 115200Baud to its host using
usart4
• monitoring of heart rate
the data and sends them back to its sender (9600Baud, uses IRQ)
usartIrq1
4.6.1 Ways of Operation: Polling versus Interrupts
The Ecg signal can be recorded fairly easily with surface
The serial interface can be read and written in two different ways:
electrodes placed on the limbs and/or the chest, see pages
below.
Polling: The input register is read periodically for new data.
Interrupts: The input register generates an interrupt in case that there is new data available.
The ISR (see Chapter 4.10) then is called and in there the data are sent. This method is more
efficient but more complex.
4.6.2 Using Polling
Configuration
The configuration is done with the Settings Wizard (see Chapter
in Figure 4.3.
Josef Goette
Send Data
Copy the files
serial.c
while ( ! ( USARTx
USARTx
DR = ( yourCharacter & 0 x1FF ) ;
35
28
Figure 4.3: USART Configuration Wizard
2
and
and use the function
serial.h
Listing 4.6: Send Data
SR & USART FLAG TXE ) ) ;
1 Intro
6–16
3.5.2
for more information), shown
2009
int ser putchar (int c)
// wait u n t i l ready
// sends yourCharacter
STM32 Cortex-M3 Tutorial
4 Peripherals
.
printf()
.
Need help?
Do you have a question about the STM32 Cortex-M3 and is the answer not in the manual?