HOWTO: Create the Blinking LED example project using S32K144 SDK

Document created by Mike Doidge Employee on Nov 8, 2017Last modified by Mike Doidge Employee on Dec 4, 2017
Version 3Show Document
  • View in full screen mode

Included in the install of S32DS for ARM, there is an example SDK project 'Blinking_LED'. This document shows the step-by-step process to create the 'Blinking_LED'. There is also a video which demonstrates the same steps.


1. New S32DS Project


2. Provide a name for the project, for example 'Blinking_LED_S32DS'. The name must be entered with no space characters.

3. Expand Family S32K1xx, Select S32K144

4. Click Next

5. Click '…' button next to SDKs

6. Check box next to S32K144_SDK_gcc. It may be necessary to check the release notes for the SDK to confirm which version to select.

7. Click OK

8. Click Finish, wait for project generation wizard to complete

9. Notice Processor Expert views have opened.

10. Make sure Blinking_LED_S32DS is selected in Project Explorer view, then from the Components - Blinking_LED_S32DS view, select:

Components -> pinmux:PinSettings

11. From the Routing tab, select the GPIO pin routing group and scroll the list until PTD Pin 15 and Pin 16 are visible

12. On the row Pin 15, in the column Pin/Signal Selection set to PTD15, in the column Direction set to Output

13. On the row Pin 16, in the column Pin/Signal Selection set to PTD16, in the column Direction set to Output

14. Go to Components view, expand pin_mux:PinSettings, select gpio_hal1:gpio_hal

15. Go to tab view Component Inspector - gpio1, Properties sub-tab, in Device setting, set to PTC

16. Click Save

17. Project -> Generate Processor Expert Code


18. If not already open, In the project window double click the main.c file to open it.

19. Expand the clock_manager component in the Components Window, then expand 'common' folder

20. Drag and drop the CLOCK_SYS_Init function into main, after the comment 'Write your code here'

21. Drag and drop the CLOCK_SYS_UpdateConfiguration function into main

22. In the CLOCK_SYS_UpdateConfiguration add the following parameters.


Notice after the second parameter is added, it turns blue and when the mouse pointer is hovered over it the value is displayed. This shows it is recognized as a defined macro.

23. Expand the pin_mux component  in the Components Window

24. Drag and drop the  PINS_DRV_Init function inside the, into main, below the clock configuration but ahead of the infinite 'for' loop

25. Expand the GPIO_HAL component in the Components Window and add the following functions in sequence

26. Drag and drop the GPIO_HAL_SetPinsDirection function into main immediately after PINS_DRV_Init

27. Drag and drop the GPIO_HAL_SetPins function into main

28. Drag and drop the GPIO_HAL_ClearPins function into main

29. For each of the GPIO_HAL functions, there are 2 arguments, first is always PTD (which is macro defined in SDK), the second is defined as follows:

GPIO_HAL_SetPinsDirection: OR-ing of LEDRGB_RED and LEDRGB_GREEN = 1 << 15U | 1 << 16U

GPIO_HAL_SetPins: Bit shift of LEDRGB_RED = 1 << 15U

GPIO_HAL_ClearPins: Bit shift of LEDRGB_GREEN = 1 << 16U

30. Include an infinite loop after these functions

31. Drag and drop the GPIO_HAL_TogglePins function in to main, and place it inside the 'for' loop.

32. Again the first argument will be PTD and the second is the same as for GPIO_HAL_SetPinsDirection above.

33. Within the 'for' loop, and prior to the GPIO_HAL_TogglePins function, add a delay of 720000 cycles

int cycles = 720000;


34. Build 'Blinking_LED_S32DS'. Select the project name in 'C/C++ Projects' view and then press 'Debug_RAM'

35. After the build completes, check that there are no errors.

36. Open Debug Configurations and select 'Blinking_LED_S32DS_Debug_RAM'


37. Check the Debugger settings and ensure that 'OpenSDA Embedded Debug - USB Port' is selected for interface.

38. Click Debug

39. Set breakpoint on GPIO_HAL_TogglePins

40. Step through initialization calls

41. To see the output register bits change, go to 'EmbSys Registers' tab and expand 'GPIO', then 'PTD' and 'PDOR'.

42. Click resume to advance to the breakpoint, see the LED on board change color

43. Click resume again and see LED change to other color