This document shows the step-by-step process for creating a simple blinking LED application for the S32Z27x family using the S32 RTD non-AUTOSAR drivers. This example used for the S32Z27x-DC EVB, which is connected via an Ethernet connection through the S32 Debugger.
Preparation
Setup the software tools
Install S32 Design Studio for S32 Platform
Install the S32Z2/E2 development package and the S32ZE RTD AUTOSAR R21-11 Version 0.9.0 P01 Both of these are required for the S32 Configuration Tools.
Launch S32 Design Studio for S32 Platform
Procedure
New S32DS Project
OR
Provide a name for the project, for example 'Blinking_LED_RTD_No_AUTOSAR'. The name must be entered with no space characters.
Expand the Family ‘S32Z27x’, and Select ‘S32Z270 (Boot core_ R52_0_0)’
Click '…' button next to SDKs
Check box next to PlatformSDK_S32ZE_2022_10_S32Z270_R52_0_0_LS (or whichever latest SDK for the S32M27x is installed). Click OK
Click "Finish" and wait for the project generation wizard to complete. Then, expand the project within the "Project Explorer" view to show its contents.
To control the LED on the board, some configuration needs to be performed within the Pins Tool. There are several ways to do this. One simple way is to double-click on the .MEX file.
By default, the Pins Tool will be presented. The S32Z27x DC EVB has user D12 LED connected to the PA_01 pin on the S32Z270 device.
To configure this pin, select the "Peripheral Signals" tab to the left of the Pins Tool perspective layout. Locate and open the SIUL2_0 from the peripheral signals tab, and from the drop-down menu, select the "gpio,1 PA_01" option as shown in the following image.
We are using Siul2_0 for GPIO usage, so we are routing the gpio,1 –> PA_01 GPIO signal to this pin.
The Direction required! menu will appear. Select Output then OK.
In Routing Details view, notice a new line has been added and highlighted in yellow.
Add ‘LED’ to the Label and Identifier columns for the Siul2_0, gpio-1 pin.
Code Preview
Go to Peripherals tool and add Gpio_Dio to enable LED blinking, it adjacent to the user LED on S32Z270 EVB.
Click on the Peripherals Tool icon in the Eclipse Perspective navigation bar.
In the Components view, click on the ‘Add a new configuration component…' button in the Drivers category. This will bring up a list of all configuration components.
Locate and select the 'Siul2_Dio' component from the list and click OK. Don't worry about the warning message – it's only indicating that the driver isn't already part of the current project. The associated driver package will be added automatically.
Note: it may be necessary to change the selection at the top from 'Present in the toolchain project' to 'All'.
The Siul2_Dio driver provides services for reading and writing to/from DIO Channels.
Now, form the toolbar selection menu at the top, select and double click on the symbol as shown as below:
Then, from the global settings window, for ComponentGenerationMethod from the drop down menu select “FunctionalGroups” from the drop down menu as shown below:
The Siul2_Dio driver requires no further configuration. Click Save to store all changes to the .MEX file.
Now. click ‘Update Code’ from the menu bar.
Now the device configurations are complete and the RTD configuration code can be generated. Click ‘Update Code’ from the menu bar.
To control the output pin which was just configured, some application code will need to be written. Return to the ‘C/C++’ perspective.
If the 'src' folder is not already open in the project window, click the '>' symbol next to it to show its contents. Then, double-click the 'main.c' file to open it. This is where you will add the application code.
To control the pin, it needs to be 'initialized' using the configuration information generated from the S32 Configuration tools. To do this, add the following line to the 'main' function after the comment 'Write your code here':
/* Initialize all pins using the Port driver */
Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);
Now, add logic to turn the LED on and off with some delays in between to make it visible blinking. Make sure the delays are long enough to be perceptible.
Add line to initialize variable uint8 i = 0;
Add line to declare variable level: volatile uint8 level;
Change the code within the provided for loop, and add the following lines:
/*logic for blinking LED 10 times*/ for (; i<10; i++)
{
Siul2_Dio_Ip_WritePin(LED_PORT, LED_PIN, 1U); level = Siul2_Dio_Ip_ReadPin(LED_PORT, LED_PIN);
TestDelay(480000);
Siul2_Dio_Ip_WritePin(LED_PORT, LED_PIN, 0U); level = Siul2_Dio_Ip_ReadPin(LED_PORT, LED_PIN);
TestDelay(480000);
}
Before the 'main' function, add a delay function as follows:
void TestDelay (uint32 delay);
void TestDelay (uint32 delay)
{ static volatile uint32 DelayTimer = 0;
while (DelayTimer<delay)
{
DelayTimer++;
}
DelayTimer=0;
}
Update the includes lines at the top of the main.c file to include the headers for the drivers used in the application:
Remove #include
"Mcal.h"
Add
#include "Siul2_Port_Ip.h"
#include "Siul2_Dio_Ip.h"
Build 'Blinking_LED_RTD_No_AUTOSAR'. Select the project name in 'C/C++ Projects' view and then press 'Build'.
After the build completes, check that there are no errors.
Open Debug Configurations and select 'Blinking_LED_RTD_No_AUTOSAR_Debug_RAM'. Make sure to select the configuration which matches the build type performed, otherwise it may report an error if the build output doesn’t exist.
Now, you need to Select the Interface (Ethernet or USB) by which the S32 Debug Probe is connected.
If connected via USB and this option is selected for interface, then the COM port will be detected automatically (in the rare event where 2 or more S32 Debug Probes are connected via USB to the host PC, then it may be necessary to select which COM port is correct for the probe which is connected to the EVB)
If connected via Ethernet, enter the IP address of the probe. See the S32 Debug Probe User Manual for ways to determine the IP address.
Click apply and Debug
To see the LED blink, click ‘Resume'.
This code as it is will blink the LED 10 times, you can make changes in for loop condition to blink it infinitely.
記事全体を表示