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

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

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

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

This document shows the step-by-step process to create a simple blinking LED application for the S32R41 family using the S32 RTD AUTOSAR drivers. This example used for the S32R41 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 S32R41 development package and the S32R41 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_With_AUTOSAR'. The name must be entered with no space characters.

  3. Expand Family S32R41, Select S32R418AB Cortex-M7
    image.png
  4.  Click Next

  5. Click '…' button next to SDKs
    DanielBarbu_0-1718796398338.png

     

  6. Check box next to PlatformSDK_SAF85_S32R41_2022_08_S32R418AB _M7_0. Click OK
    image.png
  7. And also, uncheck the other core Cortex_M7_1
    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. Select the overview tab and disable Pins tool. Make sure to overview tab windows shows settings shown as below.  Here, we are disabling pin tools and using MCAL driver from peripheral tools for using AUTOSAR drivers.
    image.png
  11. Now from Overview menu, select peripheral tools and double click to open it.
    image.png
  12. In the driver sections, “Siul2_Port_1 driver” is the non-AUTOSAR version driver and so it must be replaced. Right click on ‘Siul2_Port_1’ and remove it. Keep BaseNXP driver as it is.
    image.png
  13. Click on the ‘+’ next to the MCAL box.
    image.png
    1. Locate and then select the ‘Dem’ component from the list and click OK.
      image.png
    2. Click on the ‘+’ next to the MCAL box again, and Locate and then select the ‘Dio’ component from the list and click OK.
      image.png
    3. Click on the ‘+’ next to the MCAL box again, and Locate and then select the ‘Mcu’ component from the list and click OK.
      image.png
    4. Click on the ‘+’ next to the MCAL box again, and Locate and then select the ‘Port’ component from the list and click OK.
      image.png
      Now components tab should show like below :
      image.png
  14. Now we required to configure the different MCAL drivers that we added. Starting with Dio configuration, open the Dio configuration. No change is required for Dem configuration.
    1. Now, open the ‘DioGeneral’ tab, and select checkmark as per shown below:
      image.png
    2. Now, open the ”DioConfig” tab. In that Select  “+” sign adjacent to Dio Channel.
      image.png
    3. Then Edit Name to “Digital_Output_LED_0” and Dio Channel Id to ‘4’ instead of ‘0’.
      image.png
      From the schematic for S32R41 EVB, checking for signal line for the user LED, channel 4 is connected to user LED signal, so we use channel 4 for signal line for user LED on the chip. So, we select the signal line for Dio channel Id 4 for the LED connected on the S32R41 EVB.

  15. Now Select Port tab for Port configuration.
    1. And open the Port Configuration tab, and from that open “PortConfigSet” tab. Change the PortPin Mscr to 36 , PortPin Direction to PORT_PIN_INOUT as shown below:
      image.png
    2. Now, at the bottom you will find the “UnTouchedPortPin ’’ . Click on “+’’ and add PortPins.
      image.png
    3. Now add port pins 0, 1, 2, 3,4 as per below configuration
      image.pngimage.pngimage.pngimage.pngimage.png
  16. Now configure MCU component. Select Mcu component in MCAL, and then open the Mcu configuration.
    1. In Mcu configuration click MCUModuleConfiguration
      image.png
      and then select  “McuModesettingConf” from the dropdown menu as shown below.
      image.png
    2. From McuModeSettingConf select McuPartitionConfiguration
      image.png

      Now open “McuPartition0Config” tab.

      And under the McuCore0Configuration
      for “McuCoreClockEnable” select checkbox
      and for “McuCoreResetEnable” uncheck  the checkbox.

      Similarly, And under the McuCore1Configuration
      for “McuCoreClockEnable” select checkbox
      and for “McuCoreResetEnable” uncheck  the checkbox.

      After modification it should be as shown below:
      image.png

    3. Now open the “McuPartition1Config” tab.
      for "McuPartitionClockEnable" select checkmark to true
      and for "McuPartitionResetEnable" uncheck  the checkmark  

      And under McuCore0Configuration
      for "McuCoreClockEnable"  select checkmark to true
      and for "McuCoreResetEnable" uncheck  the checkmark

      After modification it should be as shown below:
      image.png
  17. Now, click on global setting icon as shown below:
    image.png
    And, Confirm that ComponentGenerationMethod is set to “FunctionalGroups”
    image.png
  18. Now the device configurations are complete and the RTD configuration code can be generated. Click ‘Update Code’ from the menu bar.
    image.png
  19. 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
  20. 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
  21. Before anything else is done, Initialize the clock tree and apply PLL as system clock, Apply a mode configuration, Initialize all pins using the Port driver by adding – editing code before write code here comment in main function.

           /* Initialize the Mcu driver */
           Mcu_Init(&Mcu_Config_BOARD_InitPeripherals);

           /* Initialize the clock tree and apply PLL as system clock */
           Mcu_InitClock(McuClockSettingConfig_0);

           /* Apply a mode configuration */
           Mcu_SetMode(McuModeSettingConf_0);

           /* Initialize all pins using the Port driver */
           Port_Init(NULL_PTR);
    image.png

  22. Now replace the logic of for loop as shown below code section, which will enable the LED blinking for 10 times:
    You also need to declare and initialize the loop variable:
    uint8 i = 0U;

    Then replace the code as below after write your code comment:

    /*Logic for blinking LED 10 times*/
    while (i++ < 10)
    {
          /* Get input level of channels */
          Dio_WriteChannel(DioConf_DioChannel_Digital_Output_LED_0, STD_HIGH);
          TestDelay(3000000);
          Dio_WriteChannel(DioConf_DioChannel_Digital_Output_LED_0, STD_LOW);
          TestDelay(3000000);
    }
    image.png

  23. 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
  24. Update the includes lines at the top of the main.c file to include the headers for the drivers used in the application:

    Add
    #include "Mcu.h"
    #include "Port.h"
    #include "Dio.h"
    image.png
  25. Now, in open peripheral tools again by clicking on icon as shown below.
    image.png
    And then click on global setting icon as shown below:
    image.png
    And, Confirm that ComponentGenerationMethod is set to “FunctionalGroups”
    image.png
  26. Build 'Blinking_LED_RTD_AUTOSAR'. Select the project name in 'C/C++ Projects' view and then press 'Build'.
    image.png
  27. After the build completes, check that there are no errors.
    image.png
  28. Open Debug Configurations and select 'Blinking_LED_RTD_with_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.

  29. And make selection as shown in screenshot below. You need to select the ethernet connection for S32 debugger and provide its IP address
    image.png
  30. Click Debug
  31. To see the LED blink, click ‘Resume'
    image.png
  32. This code as it will blink the LED 10 times, you can make changes in for loop condition to blink it infinitely.
No ratings
Version history
Last update:
‎06-19-2024 04:27 AM
Updated by: