HOWTO: Create a Blinking LED example project using S32K1xx RTD without AUTOSAR

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HOWTO: Create a Blinking LED example project using S32K1xx RTD without AUTOSAR

HOWTO: Create a Blinking LED example project using S32K1xx RTD without AUTOSAR

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

  1. Setup the software tools
    1. Install S32 Design Studio for S32 Platform
    2. Install the S32K1xx development package and the S32K1 RTD AUTOSAR 4.4. Both of these are required for the S32 Configuration Tools.
      image.png
  2. Launch S32 Design Studio for S32 Platform

Procedure

  1. New S32DS Project
    image.png
    OR
    image.png
  2.  Provide a name for the project, for example 'Blinking_LED_RTD_No_AUTOSAR'. The name must be entered with no space characters.
  3. Expand Family S32K1xx, Select S32K144
  4. Under Toolchain, select NXP GCC 9.2
  5. Click Next
    image.png
  6. Click '…' button next to SDKs
    image.png
  7. Check box next to PlatformSDK_S32K1_2022_02_S32K144_M4F. Click OK
    image.png
  8. Click Finish. Wait for project generation wizard to complete, then expand the project within the Project Explorer view to show the contents.
    image.png
  9. 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
  10. 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.
    image.png
  11. The Direction required! menu will appear. Select Output then OK.

    image.png

  12. In Routing Details view, notice a new line has been added and highlighted in yellow.
    image.png
  13. Add ‘LED’ to the Label and Identifier columns for the PORTD 0 pin.
    image.png
  14. Notice the changes which appear in the following views:
    1. Peripherals Signals
    2. Package
      image.png
    3. Code Preview
      image.pngimage.png
  15. Go to Peripherals tool and add Gpio_Dio.
    1. Click on the Peripherals Tool icon from the Eclipse Perspective navigation bar.
      image.png
    2. 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.
      image.png
    3. 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.
      image.png
  16. The Gpio_Dio driver requires no further configuration. Click Save to store all changes to the .MEX file.
    image.png
  17. Now the device configurations are complete and the RTD configuration code can be generated. Click ‘Update Code’ from the menu bar.

    image.png
  18. 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
  19. 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
  20. 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);
    image.png
  21. 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);
    image.png
  22. 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);
    image.png
  23. Before the 'main' function, add a delay function as follows:
    voiddelay(volatileint cycles)
    {
         /* Delay function - do nothing for a number of cycles */
         while(cycles--);
    }
    image.png
  24. 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"
    image.png
  25. Build 'Blinking_LED_RTD_No_AUTOSAR'. Select the project name in 'C/C++ Projects' view and then press 'Build'.
    image.png
  26. After the build completes, check that there are no errors.
    image.png
  27. 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.
    image.pngimage.png
  28. 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.
    image.png
  29. Click Debug
  30. To see the LED blink, click ‘Resume'
    image.png
Comments

So you add the drivers for LPUART, GPIO etc. but how do you know how to call the generated code to initialise them. i.e. How do you know or where does it tell you to use Port_Ci_Port_Ip_Init to initialise the GPIO ports? And how do you know/where does it tell you that to setup the clocks you need to call Clock_Ip_InitClock?

Andy

100% helpful (1/1)
Version history
Last update:
‎06-09-2022 01:38 PM
Updated by: