This document shows the step-by-step process to create a simple 'Blinking_LED' application using the S32K1xx RTD and the S32 Configuration Tools. This example is for the S32K144EVB-Q100 EVB, connected to a PC through USB (OpenSDA) connection.
Preparation
- Setup the software tools
- Install S32 Design Studio for S32 Platform
- Install the S32K1xx development package and the S32K1 RTD AUTOSAR 4.4. 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 Family S32K1xx, Select S32K144
- Under Toolchain, select NXP GCC 9.2
- Click Next

- Click '…' button next to SDKs

- Check box next to PlatformSDK_S32K1_2022_02_S32K144_M4F. Click OK

- Click Finish. Wait for project generation wizard to complete, then expand the project within the Project Explorer view to show the 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 by double-click on the MEX file.

- By default, the Pins tool is then presented. For the Blinking LED example, one pin must be configured as output. The S32K144 EVB has an RGB LED for which each color is connect to a separate pin on the S32K144 device. For the blue LED the desired pin is PTD0. From the Peripheral Signals tab in the view to the upper left in the standard Pins tool perspective layout, locate PORTD, then PTD0 and check the box next to it.

- 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 PORTD 0 pin.

- Notice the changes which appear in the following views:
- Peripherals Signals
- Package

- Code Preview


- Go to Peripherals tool and add Gpio_Dio.
- Click on the Peripherals Tool icon from the Eclipse Perspective navigation bar.

- From the Components view, click on ‘Add a new configuration component…’ button from the Drivers category. This will bring up a list of non-AUTOSAR components.

- Locate and then select the ‘Gpio_Dio’ component from the list and click OK. Do not worry about the warning message. It is only indicating that the driver is not already part of the current project. The associated driver package will be added automatically.

- The Gpio_Dio driver requires no further configuration. Click Save to store all changes to the .MEX file.

- 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 not already open, in the project window click the ‘>’ next to the ‘src’ folder to show the contents, then double click ‘main.c’ file to open it. This is where the application code will be added.

- Before anything else is done, initialize the clock driver. Insert the following line into main, after the comment 'Write your code here':
Clock_Ip_InitClock(Clock_Ip_aClockConfig);

- Before the pin can be controlled, it needs to be initialized using the configuration information that was generated from the S32 Configuration tools. Initialize all pins using the Port driver by adding the following line:
Port_Ci_Port_Ip_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);

- Turn the pin on and off with some delays in-between to cause the LED to blink. Make the delays long enough to be perceptible. Within the provided for loop, add the following lines:
Gpio_Dio_Ip_WritePin(LED_PORT, LED_PIN, 1U);
delay(720000);
Gpio_Dio_Ip_WritePin(LED_PORT, LED_PIN, 0U);
delay(720000);

- Before the 'main' function, add a delay function as follows:
voiddelay(volatileint cycles)
{
/* Delay function - do nothing for a number of cycles */
while(cycles--);
}

- 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 "Port_Ci_Port_Ip.h"
#include "Gpio_Dio_Ip.h"
#include "Clock_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_FLASH'. 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.


- Confirm the EVB is connected to the PC via USB cable, then check the Debugger tab settings and ensure that 'OpenSDA Embedded Debug - USB Port' is selected for interface.

- Click Debug
- To see the LED blink, click ‘Resume'
