HOWTO: Create a Blinking LED application project for S32G using S32 RTD No AUTOSAR

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

HOWTO: Create a Blinking LED application project for S32G using S32 RTD No AUTOSAR

HOWTO: Create a Blinking LED application project for S32G using S32 RTD No AUTOSAR

This document shows the step-by-step process to create a simple blinking LED application for the S32G family using the S32 RTD non-AUTOSAR drivers. For this example used for the S32G-VNP-RDB2 EVB, connected via ethernet connection through S32 Debugger.

Preparation

  1. Setup the software tools
    1. Install S32 Design Studio for S32 Platform
    2. Install the S32G development package and the S32 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. Expand Family S32G2, Select S32G274A_Rev2 Cortex-M7
    image.png
  3. Click Next
    Now, uncheck the selection mark for other two cores. 
    image.png
  4. Click '…' button next to SDKs
    image.png
  5. Check box next to PlatformSDK_S32XX_2022_07_S32G274A_Rev2_M7_0. (or whichever latest SDK for the S32G is installed). Click OK
    image.png
  6. Click Finish. Wait for project generation wizard to complete, then expand the project within the Project Explorer view to show the contents.
    image.png
  7. 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
  8. By default, the Pins tool is then presented. For the Blinking LED example, one pin must be configured as output. The S32G-VNP-RDB2 EVB has an RGB LED for which each color is connect to a separate pin on the S32G-VNP-RDB2 EVB. For the blue LED the desired pin is PA_06.

    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,6 PA_06” option as per shown in the following image.

    We are using PA_06 for the GPIO usage, so we are routing the SIUL2_0 GPIO signal to this pin. (This pin is also available for other modules like -FR, FTM, SPI_1) .
    image.png

  9. The Direction required! menu will appear. Select Output then OK.
    image.png
  10. In Routing Details view, notice a new line has been added and highlighted in yellow.
    image.png
  11. Add ‘LED’ to the Label and Identifier columns for the PORTD 0 pin.
    image.png
  12. Code Preview
    image.pngimage.png
  13. Go to Peripherals tool and add Siul2_Dio to enable LED blinking, it adjacent to the Blue LED on S32G-VNP-RDB2 EVB.
    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 all configuration components.
      image.png
    3. 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
  14. Also, select the Siul2_Port_1 tab and select the check mark against ‘Siul2 IP Port Development Error Detect’ option as below.
    image.png
  15. The Gpio_Dio driver requires no further configuration. Click Save to store all changes to the .MEX file.
    image.png
  16. Now the device configurations are complete and the RTD configuration code can be generated. Click ‘Update Code’ from the menu bar.
    image.png
  17. 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
  18. 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
  19. 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

  20. 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.
    1. Add line to initialize

      variable uint8 i = 0;
    2. Change the code within the provided for loop, and add the following lines:


      //logic for blinking LED 10 times

      for (i=0; i<10; i++)

      {

            Siul2_Dio_Ip_WritePin(LED_PORT, LED_PIN, 1U);

            level = Siul2_Dio_Ip_ReadPin(LED_PORT, LED_PIN);

            TestDelay(2000000);

            Siul2_Dio_Ip_WritePin(LED_PORT, LED_PIN, 0U);

            level = Siul2_Dio_Ip_ReadPin(LED_PORT, LED_PIN);

            TestDelay(2000000);

      }

      return (0U);

      image.png
    3. And add this line above the main() function to initialize the variable

      volatile uint8 level;

  21. 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

  22. 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
  23. Build 'Blinking_LED_RTD_No_AUTOSAR'. Select the project name in 'C/C++ Projects' view and then press 'Build'.
    image.png
  24. After the build completes, check that there are no errors.
    image.png
  25. 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
  26. Now, you need to Select the Interface (Ethernet or USB) by which the S32 Debug Probe is connected.
    image.png
    1. 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
    2. 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
  27. Click Debug

  28. To see the LED blink, click ‘Resume'.
    image.png
  29. This code as it will blink the LED times, you can make changes in for loop condition to blink it infinitely.
Comments
Anonymous

I'm attempting to use a S32G-VNP-RDB3 to evaluate the S32G3. I follow this HOWTO and what I see with a newly installed S32 DS matches fairly well until 13.

First, I don't understand the "it adjacent to the Blue LED on S32G-VNP-RDB2 EVB." This section of the HOWTO seems to be working within the S32 DS so I don't understand the reference to a LED location of the evaluation board.

Second, I don't see Siul2_Port_1 or Siul2_Dio shown from step 13b and beyond. I'm attempting to attach an image that shows what I see.

Step13.JPG

 

No ratings
Version history
Last update:
‎12-05-2022 01:54 PM
Updated by: