HOWTO: Create a simple blinking LED project using S32 Config Tool (S32V2xx)

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

HOWTO: Create a simple blinking LED project using S32 Config Tool (S32V2xx)

HOWTO: Create a simple blinking LED project using S32 Config Tool (S32V2xx)

This document shows the step-by-step process to create a simple project which recreates the included example 'hello_world_s32v234'. The purpose of this demo is to provide the user with an example application for S32V234 platform, using S32 SDK. The demo toggles two LEDs (PTA8 and PTA9). This HW used in this demo is the SBC-S32V234 EVB, connected to a PC through NXP's S32 Debug Probe or P&E Micro's debug probe.

Setup

  1. S32 Design Studio 3.1 or later installed AND S32V2xx development package installed
  2. SBC-S32V234 EVB connected to power AND switched ON
  3. Either S32 Debug Probe OR P&E Micro debug probe connected to the SBC-S32V234 EVB through JTAG connection.
    1. S32 Debug Probe connected to PC via either USB cable OR Ethernet cable (also requires power via included power supply and connected to USB port). For more information on HW setup, see HOWTO: Start Debug on an ISP Application Project with S32 Debugger and S32 Debug Probe .
    2. P&E Micro debug probe connected to PC via USB cable

Procedure

  1. Create a new application project for M4 core
    1. File -> New -> S32DS Application Project
      pastedImage_1.png
    2. Enter project name, select processor S32V234 Cortex-M4, click Next.
      pastedImage_2.png
    3. Click '...' to select the SDK
      pastedImage_7.png
    4. Select S32V234 SDK v1.0.0 (or later version)
      pastedImage_1.png
    5. Notice the box is now checked for S32 Configuration Tool. The S32 Configuration Tool is dependent upon the S32 SDK.
      pastedImage_2.png
    6. Select either S32 Debugger (default) or PE Micro GDB server. Click Finish
      pastedImage_3.png
  2. The new project appears in the Project Explorer, notice the S32V234_M4.mex file is there as well.
    pastedImage_4.png
    This .mex file contains all of the configuration data for the S32 Configuration Tool for this project. After clicking on the project name, the toolbar icon for the S32 Configuration Tool is now active.
    pastedImage_2.png
    Click the S32 Configuration Tool button or double-click on the .mex file to open the S32 Configuration Tool perspectives. Notice the new perspective buttons in the toolbar:
    pastedImage_8.png
  3. Go to Pins tool perspective, this is the default perspective that opens when the S32 Configuration Tool is launched.
    pastedImage_16.png
    1. Notice there are errors at the lower right. There is a dependency upon the PINS driver from the S32 SDK. This driver is not mandatory, and while there are some rare cases where the drivers would not be needed, in most cases the user should choose to include them.
      pastedImage_5.png                                                                                                                           To resolve the error, right-click on the error message to bring up the context menu and then select the option Add SDK component 'PINS' into the project '<project_name>'.
      pastedImage_2.png
      After selecting the context menu option, you are presented with a confirmation window to review the list of files which will be added to the project. In this case, the option did not result in any new files, so there is nothing to review. You can check a box to avoid seeing this confirmation window in the future. Click Yes to confirm the changes.
      pastedImage_3.png
    2. Select the Peripheral Signals tab at the upper left of the Pins perspectivepastedImage_10.png
    3. Check box for SIUL2pastedImage_11.png
    4. In the popup window Peripheral SIUL2, scroll to find gpio, 8 >> [A11] PA8 and gpio, 9 >> [B11] PA9. Check the box next to each.pastedImage_12.png
      1. For each pin that is selected, an additional popup menu appears. Set both pins as Output. Then click OK and then Done.
        pastedImage_13.png
      2. Set Identifiers for each as follows
        PinIdentifier
        PTA8/A11LED1
        PTA9/B11LED2
        pastedImage_1.png
  4. Go to Peripherals tool
    pastedImage_17.png
    1. Select Peripherals tab at upper left, check box to enable MC_ME
      pastedImage_22.png
    2. Click OK. Now the driver is installed.
      pastedImage_23.png
    3. Go to Clocks tool
      pastedImage_18.png
      1. Change the following settings. They are not Run Mode specific. Hovering the mouse pointer over the object in the diagram will produce a tooltip window with information about the object including the name, current setting, output value, etc.
        1. Change prescaler ENETPLL_PHI0 (.pll2Config/.phi0Divider) from 2 to 8
          pastedImage_4.png
          Change the setting by first clicking on the prescaler box in the diagram, then clicking on the value in the 'Details' panel to the right. This brings up a list of available values. Select the desired value from the list. Once successfully changed, the values will be highlighted. Alternatively, a double-click on the value inside the prescaler box will bring up a drop list of the values and the selection can be made.
          pastedImage_5.pngpastedImage_6.png
        2. Change prescaler VIDEOPLL_PHI0 (.pll4Config/.phi0Divider) from 4 to 2
        3. Change mux AUX0_MUX (CGM0_AUX0_MUX) from FIRC to DDRPLL_DFS1
          pastedImage_3.png
        4. Change mux AUX8_MUX (CGM0_AUX8_MUX) from FIRC to DDRPLL_PHI0
          To locate the next two, it is necessary to scroll down on the Clocks Diagram:
        5. Change mux CGM0_AUX7_MUX (MC_CGM_0_AUX7_MUX) from FIRC_CLK to ENETPLL_PHI0
          pastedImage_4.png
        6. Change mux CGM2_AUX2_MUX (MC_CGM_2_AUX2_MUX) from FIRC_CLK to ENETPLL_PHI0
  5. Click Update Code
    pastedImage_12.png
  6. Click OK
    pastedImage_5.png
  7. Switch to C/C++ perspective
    pastedImage_14.png
  8. Insert pins init using the configuration from 'board\pin_mux.c'
    1. If not already open, double-click on the following files from Project Explorer:
      1. 'board\pin_mux.c'
      2. 'src\main.c'
    2. Use the SDK Explorer
      1. Go to Quick Access field and enter 'sdk'
        pastedImage_11.png
      2. Select 'SDK Explorer'
        pastedImage_12.png
      3. If needed, drag the new SDK Explorer tab to the pane you prefer. In general, for this tool, a taller tab window works better.
      4. Select the project name in the Project Explorer tab and then expand the list under the SDK until you can see the list of CLOCK_DRV function defines.
        pastedImage_6.png
      5. Drag and drop the function 'CLOCK_DRV_Init()' into main() of 'main.c', after the comment '/* Write your code here */'.
        pastedImage_7.png
      6. Now locate the PINS_DRV function defines.
        pastedImage_9.png.
    3. Drag and drop the following functions into the main() function of 'main.c', after the function call CLOCK_DRV_Init():
      1. PINS_DRV_Init()
      2. PINS_DRV_ClearPins()
        pastedImage_110.png
    4. The function calls are not in the format we need so let's modify them:
      Drag and dropped from SDK ExplorerChange to this for our application
      status_t = CLOCK_DRV_Init(const clock_user_config_t*);CLOCK_DRV_Init(&clock_InitConfig0);
      status_t = PINS_DRV_Init(uint32_t, const pin_settings_config_t[]);PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);

      PINS_DRV_ClearPins(GPIO_Type* const, pins_channel_type_t);

      PINS_DRV_ClearPins(LED1_PORT, ((1<<LED1_PIN)|(1<<LED2_PIN)));
      clock_InitConfig0 is defined in 'board/clock_config.c'
      NUM_OF_CONFIGURED_PINS, LED1_PORT, LED1_PIN, LED2_PORT, LED2_PIN are defined in 'board/pin_mux.h'
      g_pin_mux_InitConfig_Arr is defined in 'board/pin_mux.h'

      LED1_PORT == LED2_PORT
  9. Replace the contents of the FOR loop to toggle the pins (PINS_DRV_TogglePins() comes from SDK Explorer)
    OriginalNew
    for(;;)
    {
         if(exit_code != 0)
         {
              break;
         }
    }
    for (;;)
    {
         /* Insert a small delay to make the blinking visible */
         delay(720000);

         /* Toggle output value LED1 & LED2 */
         PINS_DRV_TogglePins(LED1_PORT, (1 << LED1_PIN)|(1 << LED2_PIN));
    }
  10. Insert delay function code in main.c
    delay()
    void delay(volatile int cycles)
    {
         /* Delay function - do nothing for a number of cycles */
         while(cycles--);
    }
  11. Now main.c should look as follows
    pastedImage_23.png
  12. Build the project
    pastedImage_93.png
  13. Now we have the ELF file
    pastedImage_24.png
  14. We are ready to run on the hardware. Open the Debug Configurations
    pastedImage_92.png
  15. Select the debug configuration within the debugger grouping for the debugger that was chosen in the new project wizard (step 1f), and for build type Debug_TCM
    S32 Debugger/S32 Debug Probe
    pastedImage_95.png
    Select the Debugger tab. Some setup is required to configure how we are connected to the S32 Debug Probe

    There are two options:

    • Ethernet
    • USB

    pastedImage_4.png

     

    If connecting the Probe via Ethernet, please refer to the Quick Start Guide or S32 Debug Probe User Guide provided with the S32 Debug Probe for instructions on how to connect it and determine the Hostname or IP address.

     

    pastedImage_6.pngpastedImage_7.png

     

    If connecting the Probe via USB, then the COM port will appear in the Port selection setting. If you have more than one S32 Debug Probe connected, you will need to determine which COM port is the correct one, otherwise, only the COM port for your S32 Debug Probe will appear.

     

    pastedImage_5.png

    PEMicro GDB Server
    pastedImage_99.png
  16. When debug probe setup is done, then click Debug to run the code.
    Agree to launch the debug perspective
    pastedImage_100.png
  17. Now the debugger starts and you can see it has stopped on the default breakpoint at the first line in main(). From here you can Resume, Step, set a breakpoint, set watch variables and monitor registers.
    pastedImage_101.png
  18. If you Resume, then you will see the LEDs on the EVB blinking. You can set a breakpoint on the PINS_DRV_TogglePins() and use Resume to see the LEDs come on and off.
    pastedImage_25.png
No ratings
Version history
Last update:
‎07-08-2019 02:50 PM
Updated by: