Introduction
Scope -
This application note describes how to configure the IO stack into an AR project. The document contains an explanation step by step of the workflow to follow to obtain a working project.
The steps required to create and initially configure an RTA-CAR project are covered in the other workflows in this User Guide, so in this workflow we take an existing single core project (based on the VRTA_Standard Starter Kit for RTA-CAR 9.2) and we explain how to configure the IO stack.
This application note could be used as a reference for any generic AR based project.
Definitions and Abbreviations -
BSW: AUTOSAR Basic Software, Hardware independent service layer.
RTE: AUTOSAR Real Time Environment.
OS: AUTOSAR Operating System.
SWC: Software Component.
Toolchain
It is assumed you are using the RTA-CAR 9.2.0 toolchain:
RTA-CAR 9.2.0 toolchain | |
---|---|
ISOLAR-AB | v 9.2.0 |
RTA-RTE | v 7.5.0 |
RTA-BSW | v 6.1.2 |
RTA-OS | v 6.2.0 |
Prerequisites
The workflow below is designed to be stand-alone.
It is assumed that you are already familiar with how to create and configure an AUTOSAR project with ISOLAR-AB.
If you’ve not done so already, we recommend that you review (and preferably work through) Workflows 01, 02 and 03 to gain a better understanding of ISOLAR-AB and the tools available to create and configure an AUTOSAR project.
Workflow
1 - Create new SWC
Begin by creating a new SWC that will handle the ECU I/O (you can also simply update an existing
SWC).
To do that, right click on Software–>Create Component | Application Sw Component Type
Use ISOLAR-A to create the SWC and add to this SWC the reuired components: an
internal behaviour, at least one runnable, sender/receiver ports to send data related to ports.
We are going to use different port interfaces: boolean type for DIO, uint32 for analog input
and a custom interface with two data elements of type uint32 for PWM.
2 - Create new Port Interfaces
Before adding a port to the SWC you must create the proper port interfaces; right click on Software and select Create Interface–>Create Port Interface | Sender Receiver Interface
Create the DIO interface:
Double click on the interface to open it and create two VariableDataPrototypes, select the interface from the table and then press Add VariableData Prototype button.
Type the desired name for the Variable Data Prototype and set its type reference; see the picture below for the values set for this example:
Create 2 additional interfaces ADC_IF of type uint32 and PWM_IF of type uint32 as shown below:
3 - Create new Ports
Double click on IO_SWC created to open it and click on PPorts… to add a new port:
In the dialog window, select the Port Interface previously created:
Create 3 more ports:
- PWM_IF PPort
- DIO_IF Rport
- ADC_IF RPort
The ports can be renamed and the results of this step are show below:
4 - Create new Internal Behavior
To create runnables into a SWC an Internal Behavior container must be created; to do that ,click on the green plus button on the upper right of the Application SWC and set its name in the dialog window:
5 - Create new runnables for IOSWC
To create runnables, switch to the “Functions” tab and press the Runnables button
6 - Create Data access points for new runnables
For the runnable to access the SWC Port, it must have Data Access Points; select the Sending runnable and switch to Tab Data Access Points; then press the Access Points… button to create a new one. The data access points show on the right side should be created:
7 - Create events for IOSWC
Finally, the events that will trigger the runnables must be created. Switch to Events tab and press the arrow next to the green plus button; from the context menu select a Timing Event to trigger RE_IO:
NB: for the timing event, remember to set the Timing period in the table:
8 - Create the ECU Hw Abstraction component
As previously done for the application SWC, the same steps must be followed to create a IoHwAbstractionSWC; first, create the IoHwAbstractionSWC; right click on Software and select Create Components|Ecu Abstraction Sw Component Type:
9 - Create ports for IoHwAbstractionSWC
Since the interface has been already created; we can now create the SWC ports; these must be complementary to the ones in the IOSWC; the picture below shows the ports to be created on the IoHwAbstractionSWC:
10 - Create IoHwAbstractionSWC Internal Behavior
To create runnables in an SWC an Internal Behavior container must be created; to do that, click on the green plus button on the upper right of the IoHwAbstractionSWC and set its name in the dialog window:
12 - Create IoHwAbstractionSWC runnables
Create the runnables, in this case since data may be received not all at the same time, a new
runnable will created for each port:
13 - Create Data Access Points for all runnables
Each runnable will need the necessary data access points. Configure them as shown below:
- SetDO:
- ReadDI:
- ReadADC:
- SetPWM:
14 - Create IoHwAbstraction events
Now create events to trigger the runnables. The runnables used to set output pin values will
be triggered by data received events connecting the events to the RPort linked to the SWC;
the input pin value will update the PPorts periodically. The required events are shown below:
15 - Add new components to composition
In order to map the SWCs on the ECU, they must be added into the TopLevelComposition, this can be found under Compositions under Software.
Populate the composition by opening it and adding SWC prototypes; to add SWC click on the arrow next to the green plus button and select Component Prototype:
16 - Map SWCs to ECU
To add the new SWCs you must go into the SWC to ECU mapping editor, right click on the system and select Open With –> SWC to ECU mapping editor:
Expand the TopLevelComposition on the right hand side to show all the SWC components, drag and drop the components into the relevant ECU:
17 - Create ECU Extract
Once the ECU configuration is over, create the ECU extract; right click on the system and select Create ECU Extract:
18 - Map entities to tasks
Go into the ecuc value collection under bsw modules then switch to “Entity to Task Mapping”, drag and drop the SWC runnables under the configured Os task:
19 - PORT module Configuration
In this part ISOLAR-B is used to configure the Port and some other modules.
The port module will be configured as first, in this module all the pins involved in the other
modules must be configured. In this AN the Port module will have 4 pins.
Start creating a new Port module:
Now configure at first the PortGeneral container:
NB: in this configuration some parameters values are strictly connected to virtual hardware
used. User should adjust these values to his own hardware.
Then configure the PortConfigSet container creating four pins. For DIO pins set the initial
mode to “PORT_PIN_MODE_DIO” and other parameters as desired. For ADC and PWM the
MCAL used requires a parameter not shown in ISOLAR-B so the arxml file must be updated out
of the authoring tool. The parameter to be added is PortPinMode and its value has to be
“PORT_PIN_MODE_ADC” or “PORT_PIN_MODE_PWM”; the same value has to be set to
parameter PortPinInitialMode.
Manually edit the arxml file to add PortPinMode and PortPinInitialMode to both PortPin_ADC and PortPin_PWM:
20 - ASW Update
Create an IO_SWC.c file in the asw folder, adding the following code;
this function writes and reads ports periodically:
21 - DIO module Configuration
Create DIO in the same way that you created the port module and store it in the same arxml file (IOStack.arxml)
Configure the DioGeneral container like shown:
In this AN we will configure 2 DIO: one digital input and one digital output. Switch to the
DioConfigSet container and create 2 DioPorts containerd. Inside each DioPort configure:
- DioPortID; NB: this ID has to match the ID in the Port module (see later)
- a DioChannel with its ID
To do this right click on DIO in the BSW editor and click New Child –>DioConfig
This will create DioConfig and populate it with 1 port. We need to create 1 more port which can be done be right clicking on DioConfig and clicking New Child –> DioPort:
Configure each port as shown below:
Now you will need to create a channel in each of the ports. Do this by right clicking on the correct port and then clicking New Child –> DioChannel:
Configure each channel as show below:
22 - PWM Module Configuration
Create a new PWM module and put it in the same arxml file where the previous modules have
been added.
Configure the PWMGeneral container; the virtual hardware has some limitations on this
module that is the reason for having some parameters set to false; user should adjust these
parameters to desired values.
Now configure the container PwmConfigurationOfOptApiServices to define which APIs will be
avalable to ASW:
Finally, configure the PwmChannelConfigSet container; configure as many channels as
desired bearing in mind that if you are planning to use the API “SetPeriodAndDuty” then the
parameter “PwmChannelClass” must be set to “PWM_VARIABLE_PERIOD”.
The PWM channel also needs an id. This option isnt available in ISOLAR so you will need to manually update the arxml file to add this:
23 - ADC Module Configuration
Create a new ADC module and put it in the same arxml file where the previous modules have
been added:
Configure AdcGeneral container. These settings are strictly hardware dependent. The configuration used for a virtual target will be included below.
And for a virtual target:
Configure as many AdcChannels as needed in the AdcConfigSet container and put them into
groups; for virtual target mcal generator at least one channel inside one group must be
defined:
Again the AdcChannelId and AdcGroupId cannot be set in ISOLAR so must be added to the arxml file manually:
24 - ECuM Module Update
Some of the new modules must be initialized using the EcuM module. The DIO module does not require an initialization function
while Port, Adc, Pwm do.
Edit the EcuM container EuMConfiguration/EcuMCommonConfiguration/EcuMDriverInitListOne
adding the initialization functions for the three mentioned modules:
Once you have done this, add header files related to the new modules to the EcuMGeneral/EcuMRbIncludeHeaderList:
Once done this step generate the BSW code.
25 - Integration Code
Update the integration code files (EcuM_User.h in this case) adding the definition of new module configuration data used in initialization functions:
26 - IoHwAbstractionCode
The last thing to do is to create a IOHwAbstractionSWC.c file in the asw folder and add the following code:
27 - Generate RTE
Now click the small drop down arrow next to the RTA Code Generator:
Select Generate RTA-RTE from the list below:
After this step, generate the OS