3.7 Simulation
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
Listing 3.1:
Minimal Code for a Counter on GPIOB
1
/
∗
Name :
gpio . c / P r o j e c t gpio1
∗
D e s c r i p t i o n : Counter on GPIOB
∗
Version :
V1 . 0 0 / 1 5 . 0 7 . 2 0 0 9
∗
/
# include
<
s t m 3 2 f 1 0 x l i b . h
>
// STM32F10x L i b r a r y D e f i n i t i o n s
6
# include
"STM32_Init.h"
// STM32 I n i t i a l i z a t i o n
i n t
main (
void
)
{
i n t
i , j = 0 ;
// c o u n t e r v a r i a b l e s
s t m 3 2 I n i t ( ) ;
// STM32 setup
11
while
( 1 )
{
// Loop f o r e v e r
j ++;
// i n c r e a s e f i r s t c o u n t e r
i f
( j ==1000)
{
GPIOB
−
>
ODR = ( GPIOB
−
>
ODR & 0 xFFFF0000 )
|
i ;
// w r i t e i t o GPIOB
16
j = 0 ;
i f
( i ==0xFFFF ) i = 0 ;
i ++;
}
}
21
}
3.7 Simulation
Before we download the project to the development board we’ll do a simulation in
µ
Vision3 to
see if everything works. Therefore click on
Debug
7→
Start/Stop Debug Session
or it’s icon. This will
open the debug mode and show a warning that you are using the evaluation mode. Click OK and
open the GPIOB port with
Peripherals
7→
General Purpose I/O
7→
GPIOB
.
Figure
shows the debug mode. In the top left corner the simulation is handled. To let the simu-
lation run until a breakpoint is reached, press
Run
. In our example you’ll see the GPOIB counting
up binary and the variable
i
in the Watch Window increasing. You can change the variables in the
Watch Window by double clicking on them. A breakpoint can be set by a double click on the left
area of the code window. A running simulation can be interrupted by pressing the
stop
icon.
Pressing
reset
will set the CPU to its initial State.
In case you want to step through your code it’s not very nice to use breakpoints since these are
limited to 8. Therefore use the step commands.
Step into
will enter into every called function.
Step
over
doesn’t enter the function.
Step out
lets the code in the function execute, leave the function
and wait for further commands.
Run to cursor line
lets the code run until the line is reached where
the cursor is.
Lukas Kohler
17