Unit 1
Unit 1
Content
1. Basics ................................................................................................................................................. 1
1.1. ECUs in Modern Automobiles ............................................................................................. 3
1.2. Sensors – ECUs – Actuators .............................................................................................. 4
1.3. Evaluation Board ................................................................................................................... 4
1.4. Practical Examples ............................................................................................................... 5
2. Experimental Procedure .................................................................................................................. 6
2.1. Programming Microcontrollers........................................................................................... 6
2.2. Initial Setup ............................................................................................................................ 7
3. Unit 1 Tasks..................................................................................................................................... 10
3.1 Task 1 - Pin Configuration ....................................................................................................... 10
3.2 Task 2 – Analog Pin Configuration ........................................................................................ 11
3.3 Task 3 – Buttons and Timers .............................................. Fehler! Textmarke nicht definiert.
List of References ............................................................................................................................... 12
1. Basics
For more than a hundred years, motor vehicles are produced and improved. The use of
microelectronics provided new possibilities for engineering and implementation of complex
functionalities for automobiles. Today most car drivers use their automobile for more than one
hour per day, this results in increasing demands of the driver to the vehicle. To meet all the
demands the usage of hardware and software in automobiles increases rapidly. The fast and
reliable reaction of automotive functions is assured by software, electronic control units and
their communication amongst each other. Furthermore former mechanical functions were
replaced by software, electronic control units, sensors and actuators. Today luxury class
automobiles contain up to 80 connected electronic control units i.e. engine management,
airbag control, power locks and electric windows. In the case of the electric windows the
software automatically reverses/stops the window motor if it senses an obstruction while
closing.
1
ASE Practical: Automotive Software Engineering Practical Course - Unit 1
Nowadays 90% of the innovations in car development concern the electronics and the
software. That includes the conversion of classic mechanic functions as well as new features
for example the automatic parking system.
For the practical automotive specific terms are necessary which are explained in Table 1.
2
ASE Practical: Automotive Software Engineering Practical Course - Unit 1
1.1. ECUs in Modern Automobiles
Increasing customer demands, such as lower fuel consumption, improving of driving safety
and comfort are closely related to the use of more and more electronics and software in
modern automobiles. The requirements of the ECUs in today´s automobiles are the following:
• Reliable under rough and changing ambient conditions like temperature, humidity and
vibration
• High demands to the dependability and availability
• High demands to the security
ECUs work as a reactive system. The driver has no influence on the functionality except from
activating sensors (e.g. switches).
This easy, general example demonstrates the interconnection of the controllers and their
communication over a bus. It is typical for a bus that the data transfer is realized via messages.
Therefore the developer has the ability to send information resp. messages (for example the
outdoor temperature) from one ECU to 1 or several others over the bus. The installed ECUs are
divided into the following subsystems:
• Engine
• Chassis
• Car body
• Multimedia
• Security
To stress the importance of the interconnection and the categorization of ECUs, the following
example shall be used. The ACC (Adaptive Cruise Control) is an add-on for the cruise control.
The system maintains a steady speed as set by the driver and automatically keeps the
necessary security-distance. When approaching a slower vehicle the speed is adjusted to the
speed of the preceding vehicle and thus the security distance is kept. If the distance increases
the systems accelerates up to the defined speed. To realize this function several ECUs are
necessary in the automobile. The ACC-ECU communicates with the engine-, the ESP- and the
gearbox ECUs to adjust the driving speed. ESP is necessary to selective decelerate individual
wheels to avoid the vehicle breaks away.
3
ASE Practical: Automotive Software Engineering Practical Course - Unit 1
This simple example shows the importance of the communication between the affected ECUs.
Only by interaction of the different ECUs the functionality of the ACC can be displayed. It also
shows that simple features need complex implementations.
The following graphic shows the relation between sensor, ECU and actuator.
The graphic shows the function of an electronic window. A simple switch serves as the sensor.
Once the switch is pressed the ECU activates the actuator, in this case the electric window
motor. The ECU is responsible for automatic reversing the electric windows if it senses an
obstruction while closing.
There are several sensors and actuators already on the board, no more components are
needed for simple experiments. Please study the tasks under point 2 and the sources provided
on OPAL.
4
ASE Practical: Automotive Software Engineering Practical Course - Unit 1
1.4. Practical Examples
Closed control loop
Many ECUs form closed control loops, where an
actor is controlled based on the readings of a
sensor. By driving the actor the measured
environment is influenced and subsequently the
future readings change.
A typical example for this is climate control, where
the sensor is a thermometer and the actor is the
heating / cooling unit. Based on the target
temperature the ECU heats or cools the inside of the
car or stays idle.
Another example is the window regulator. The
switch panel serves as sensor and the window
motor as the actuator. The entrapment protection
and the up and down moving functions are software
implementations on the ECU.
5
ASE Practical: Automotive Software Engineering Practical Course - Unit 1
2. Experimental Procedure
In general, the pins of the microcontroller are organized by ports. Every port of the
microcontroller has a set of pins. Each port can only perform certain tasks due to limited
support for remapping peripheral functions. More details of it can be found in the reference
manual.
Figure 3 shows an extract of the reference manual of the microcontroller, which can be found
at [2]. It shows the structure of the pad configuration register (PCR) of the System Integration
Unit Lite (SIUL) module, which is used to configure digital in- and outputs.
To access the PCR registers in C code, it is possible to directly access the base address of the
registers or to write “SIU.PCR[X].R“, which is a macro defined in the “xpc56el.h“ header file.
The meaning of bit fields is also described in the reference manual.
Example:
Objective: Configure port B8 of an SPC56EL60 microcontroller as a digital output and then set
it low.
6
ASE Practical: Automotive Software Engineering Practical Course - Unit 1
Look into the reference manual and find the port pin. As shown in Figure 4, port pin B8 supports
general purpose in- and output (GPIO) and the corresponding PCR number is 24 (PCR[24]).
To configure an I/O pin the “output buffer enable” bit (OBE) must be set. In Figure 3 the OBE
bit is at position 6. To set this bit, “0x0200” (hexadecimal), “0b0000001000000000” (binary),
or “512” (decimal) could be written to the register, but there are also several other ways to set
this bit. The compiler used in this practical course doesn’t care about the way it is done. In C it
can look like this for port B8 of the STM SPC56EL60 microcontroller:
SIU.PCR[24].R = 0x0200; /* configures port B8 as output */
To activate the output as “low signal”, a “0” must be written to the corresponding general
purpose digital output register (GPDO).
SIU.GPDO[24].R = 0; /* sets port B8 low */
Every module on the microcontroller can be configured in a similar way. In the reference
manual all functionalities and registers are described. These are the basics of microcontroller
and driver programming.
Note: Every microcontroller has its own individual modules and registers. That’s why it is
necessary to read the reference manual and to program new drivers when the hardware is
changed.
The first step is opening the “SPC5Studio Ide” that is located on Desktop or on windows
menu in “SPC5Studio” folder.
After successfully opening the Ide then click on File -> Open Projects from File System :
7
ASE Practical: Automotive Software Engineering Practical Course - Unit 1
In the next window click Directory -> (Locate the folder which contains the project of Unit_1
downloaded from OPAL) -> Finish. Now you will be able to see your project folder in “Project
Explorer” Menu located in left side of the IDE.
The project “Unit1\Unit1“ (Source code in the appendix) has to be opened in the SPC5 Studio
IDE. Analyze and study the source code on the file “main.c”. Building the project is done by
pressing the “Build SPC5 Application” button in the IDE. After building the project successfully
without any error, the next step is debugging. Clicking on “Launch UDE debugger” button on
the IDE will open the debugger window. Now the output file generated by the Ide shall be loaded
to the debugger as shown in the figure above :
8
ASE Practical: Automotive Software Engineering Practical Course - Unit 1
After loading the output file to the debugger, the previously flashed code shall be erased by
clicking Erase -> Erase whole FLASH Module -> Start. Next step is flashing the output file that
we loaded to the controller by clicking Program All.
Finally start the program by either clicking the “Start Program” button or by clicking F5.
9
ASE Practical: Automotive Software Engineering Practical Course - Unit 1
3. Unit 1 Tasks
List of References
[1] Schäuffele, Jörg; Zurawka, Thomas: Automotive Software Engineering. Wiesbaden: Springer
Vieweg, 2013
[2] STMicroelectronics: SPC56EL60x Family Reference Manual. URL:
https://www.st.com/en/automotive-microcontrollers/spc56el60l5.html (15.04.2020)
[3] Raisonance S.A.S.: REva v3 User Guide. 2010