This document shows the step-by-step process to create a simple blinking LED application for the S32R45 device using the S32 RTD non-AUTOSAR drivers. For this example used for the S32R45 EVB, connected via ethernet connection through S32 Debugger.
Preparation
- Setup the software tools
- Install S32 Design Studio for S32 Platform
- Install the S32R45 development package and the S32R45 RTD AUTOSAR 4.4. Both of these are required for the S32 Configuration Tools.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202672i40FC2949FFC6E40F/image-size/large?v=v2&px=999)
- Launch S32 Design Studio for S32 Platform
Procedure
- New S32DS Project
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202674i50B5668E1E1F39A7/image-size/large?v=v2&px=999)
OR
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202675i7CE05F1A7EABA1E8/image-size/large?v=v2&px=999)
- Provide a name for the project, for example 'Blinking_LED_RTD_No_AUTOSAR'. The name must be entered with no space characters.
- Expand Family S32R45, Select S32R45 Cortex-M7
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202676i2C6D2C67E8214C05/image-size/large?v=v2&px=999)
- Click Next
- And Click '…' button next to SDKs
- Check box next to PlatformSDK_S32RXX_4_0_0_S32R45_M7_0. (or whichever latest SDK for the S32R45 is installed). Click OK
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202679i3F908D52FF2AD54D/image-size/large?v=v2&px=999)
- Now, uncheck the selection mark for other core, i.e. for Cortex-M7-1 , Cortex-M7-2
- Click Finish. Wait for project generation wizard to complete, then expand the project within the Project Explorer view to show the contents.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202692iC301A06427EA9C27/image-size/large?v=v2&px=999)
- 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.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202693i9CCD44523572AB67/image-size/medium?v=v2&px=400)
- By default, the Pins tool is then presented. For the Blinking LED example, one pin must be configured as output. The S32R45 EVB has an user LED connected pin is PD_05.
From the Peripheral Signals tab left to the Pins tool perspective layout, locate Open the Siul2_0 from the peripheral signals tab. And from the drop down menu select “gpio,53 PD_05” option as per shown in the following image.
We are using PD_05 for the GPIO usage, so we are routing SIUL2_0 GPIO signal to this pin.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202696i2B4DDC10AB6613F8/image-size/medium?v=v2&px=400)
Select gpio53 -> PD_05 as shown below :
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202698iD62E8E41CEA9304D/image-size/medium?v=v2&px=400)
- The Direction required! menu will appear. Select Output then OK.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202701iB9DC1F0337C565D8/image-size/medium?v=v2&px=400)
- In Routing Details view, notice a new line has been added and highlighted in yellow.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202703i0CA5FEBA19CD6146/image-size/large?v=v2&px=999)
- Add ‘LED’ to the Label and Identifier columns for the PORTD 5 pin.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202705i6FF5B95B7DAD1128/image-size/large?v=v2&px=999)
- Code Preview
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202707iB0AE9E5B54FCB20C/image-size/large?v=v2&px=999)
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202711iB4A20197F3E69FBF/image-size/large?v=v2&px=999)
- Go to Peripherals tool and add Siul2_Dio to enable LED blinking, it adjacent to the user LED on S32R45 EVB.
- Click on the Peripherals Tool icon from the Eclipse Perspective navigation bar.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202712i7D1A3640EE5AE002/image-size/large?v=v2&px=999)
- From the Components view, click on ‘Add a new configuration component…’ button from the Drivers category. This will bring up a list of all configuration components.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202713iF45092ADF98BED46/image-size/large?v=v2&px=999)
- Locate and then select the ‘Siul2_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. Note: It may be necessary to change the selection at the top from ‘Present in the tool-chain project’ to ‘All’.
The DIO driver provides services for reading and writing to/from DIO Channels.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202714i4D09A0B5F885BE29/image-size/large?v=v2&px=999)
- The Gpio_Dio driver requires no further configuration. Click Save to store all changes to the .MEX file.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202715iCF6C1A7BA0BA7FFA/image-size/large?v=v2&px=999)
- Now the device configurations are complete and the RTD configuration code can be generated. Click ‘Update Code’ from the menu bar.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202716i4965A987356F42E0/image-size/large?v=v2&px=999)
- To control the output pin which was just configured, some application code will need to be written. Return to the ‘C/C++’ perspective.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202717i0C595F719D331429/image-size/large?v=v2&px=999)
- 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.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202718i5445B41501E13ED4/image-size/large?v=v2&px=999)
- 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: Insert the following line into main, 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);
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202719i8CC863B91D25FB67/image-size/large?v=v2&px=999)
- Now, add logic for the LED turn and off. To 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.
- Add line to initialize variable
uint8 i = 0;
- Change the code within the provided for loop, and add the following lines:
//logic for blinking LED 10 times
while (i++ < 10)
{
Siul2_Dio_Ip_WritePin(LED_PORT, LED_PIN, 1U);
TestDelay(4000000);
Siul2_Dio_Ip_WritePin(LED_PORT, LED_PIN, 0U);
TestDelay(4000000);
}
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202720iDFE53E30F62EE309/image-size/large?v=v2&px=999)
- 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;
}
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202721i94566397C2295A56/image-size/medium?v=v2&px=400)
- 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"
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202722i9D152C18F5786B82/image-size/large?v=v2&px=999)
- Build 'Blinking_LED_RTD_No_AUTOSAR'. Select the project name in 'C/C++ Projects' view and then press 'Build'.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202723i8794006714A358C2/image-size/large?v=v2&px=999)
- After the build completes, check that there are no errors.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202724i5829C4411E175AE4/image-size/large?v=v2&px=999)
- 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.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202725i60E3DA7CA4745113/image-size/large?v=v2&px=999)
- Now, you need to Select the Interface (Ethernet or USB) by which the S32 Debug Probe is connected.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202726iEBAFD68936B98001/image-size/large?v=v2&px=999)
- 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)
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202727i3DA4A9AA2BF5BC4D/image-size/large?v=v2&px=999)
- 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.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202728iD562B9CF4EBB2FF4/image-size/large?v=v2&px=999)
- Click Debug
- To see the LED blink, click ‘Resume'.
![image.png image.png](https://community.nxp.com/t5/image/serverpage/image-id/202729i0F95F94457681F05/image-size/large?v=v2&px=999)
- This code as it will blink the LED 10 times, you can make changes in for loop condition to blink it infinitely.