HOWTO: Create a Blinking LED Project (MPC5748G)

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

HOWTO: Create a Blinking LED Project (MPC5748G)

HOWTO: Create a Blinking LED Project (MPC5748G)

Perhaps you are just using the S32DS for Power for the first time, and maybe you've seen the provided examples and want to learn a bit more about how they were created. Here are the steps to create a simple application for the MCP5748G MCU which toggles a pin causing one of the user LEDs to blink. This example includes use of the S32 SDK for Power Architecture.

Please note: There are options in the steps below to cover the case of either the DEV-KIT(DEVKIT-MPC5748G) or Motherboard(X-MPC574XG-MB) with Daughtercard(X-MPC574XG-324DS) hardware EVBs.

1) Launch S32DS for Power

2) Select File -> New -> New S32DS Project


3) Enter a name for the project, such as 'BlinkingLED'

4) Locate, from the list of processors, Family MPC574xG -> MPC5748G, and select it.

5) Click Next


6) Uncheck the boxes for cores e200z4 and e200z2, leaving just e200z4 (boot) checked. This is because the application will run on the boot core and will not use either of the other two cores.

7) Click on the '…' button next to SDKs, in the column for BlinkingLED_Z4_0.


8) Check the box next to MPC5748G_SDK_Z4_0_GCC to include support for the SDK within the new project and for the core we have selected.

9) Click OK


10) Click Finish to close the New Project wizard window and start the project generation.

11) Wait a minute or two for the project generation script to complete.


12) Go to the 'Components Library' view then locate and double-click on 'pit' component to add it to the project. 


Alternatively, right-click and select Add to project.


You can verify it was added by inspecting the 'Components - <project_name>' view.


13) With 'pit' selected in the 'Components - BlinkingLED_Z4_0' view, go to the 'Component Inspector' view to see the configurations for the PIT component. Locate the section for 'Configuration 0'. You may have to scroll down to see it. Change the 'Time period' setting to 500000 microsec(0.5 sec). Note that we are editing the settings for Clock configuration 'clockMan_InitConfig0', you will need the name of this configuration later.


14) Back in the 'Components' view, select 'pin_mux' component and return to the 'Component Inspector' view


15) From the 'Routing' tab, select the 'SIUL2' sub-tab and scroll down the Signals list until 'GPIO_0' (DEV-KIT) or 'GPIO_99' (Motherboard) is shown.


16) Change to the following settings:

a. Pin/Signal Selection: PA[0] (DEV-KIT) / PG[3] (Motherboard)

b. Direction: Output

Pin PA0/PG3 is connected to user LED 2 on the evaluation board.


17) All configuration settings are now complete. Click Generate Processor Expert code button in the 'Components' view or use the menu bar Project-> Generate Processor Expert Code.


18) Wait for the code generation to complete.


19) Now, from the 'Project Explorer' view, the generated code is visible in the folder 'Generated_Code' of the project 'BlinkingLED_Z4_0'.


20) If not already open, in 'Project Explorer' open the file 'BlinkngLED_Z4_0\Sources\main.c' by double-click. This will open the file in the editor view.


21) Scroll down until the following comments are shown:

/* Write your code here */

/* For example: for(;;) { } */


We need to add some code here to initialize the clocks, timers and pins. Then we will setup a timer interrupt handler to toggle the pin.

22) First we need to initialize the clocks. From the 'Components' view, expand 'clock_manager' and then drag & drop CLOCK_DRV_Init function into main() of main.c, just after the comments identified in the previous step within the text editor view.



23) Add to the function CLOCK_DRV_Init(), the parameter &clockMan1_InitConfig0 to give it the address of the user configuration structure generated by ProcessorExpert in '.../Generated_Code/clockMan1.c'. This is the clock configuration for which we edited the timer period in an earlier step.


24) Next we need to initialize the pins. Back in the 'Components' view, expand the 'pin_mux' then drag and drop the function PINS_DRV_Init after the clock initialization.



25) Again from the 'Components' view, expand 'interrupt_manager', then drag & drop INT_SYS_InstallHandler in 'main()'. This installs the PIT channel 0 interrupt handler.

26) Enter the parameters: PIT_Ch0_IRQn, &pitCh0Handler, NULL



27) In the User includes section at the start of main.c, add the implementation of the handler

a. Create a function called pitCh0Handler

b. In the function body: clear the interrupt flag and toggle LED

  /* IRQ handler for PIT ch0 interrupt */

  void pitCh0Handler(void)


/* Clear PIT channel 0 interrupt flag */

PIT_DRV_ClearStatusFlags(INST_PIT1, 0U);

/* Toggle LED (GPIO 0 connected to user LED 2) */


/* SIUL2->GPDO[99/4] ^=SIUL2_GPDO_PDO_4n3_MASK;*/ // Motherboard


Note: Get PIT_DRV_ClearStatusFlags by drag & drop from the 'pit' component.



28) In 'Components' view, expand 'pit' component and then drag & drop PIT_DRV_Init, PIT_DRV_InitChannel & PID_DRV_StartChannel in main() after INT_SYS_InstallHandler().

29) Fill in the second parameter of the last function(channel number): 0U


30) Build the code. Click the down arrow next to the 'Build' button and select Debug_RAM. Check that there are no build errors.


31) Enter the 'Debug Configurations' menu:

a. From the menu bar, Run -> Debug Configurations...


b. From the toolbar, down arrow next to Debug button -> Debug Configurations...


32) The Debug Configurations window appears. Select the configuration BlinkingLED_Z4_0_Debug_RAM from within the GDB PEMicro Interface Debugging group.


33) Select the 'Debugger' tab to setup the connection to the debugger hardware device.

34) Select the PEMicro Interface which corresponds to your setup:

a. If using the motherboard, you will likely use the USB Multilink, which is connected to your PC via USB cable (type A on one end, type B on the other) and is connected to the motherboard via the 14-pin JTAG cable.


b. If using the DEV-KIT board, you will likely choose the OpenSDA, which is integrated into the DEV-KIT board and is connected with just a USB cable (type A on one end, type micro on the other).



35) Click Debug To launch the debugging session. This will also open the Debug perspective.

36) In the Debug perspective, once the debugging session has fully launched, the code will be executed to the start of main(), where a breakpoint was automatically set for you. Press Resume button in the toolbar, Run -> Resume in the menu bar, or F8 on your keyboard to run the application.


37) You should now see the User LED2 on the board blink every 0.5 seconds.

38) To see the value of the output register bit for the output pin connected to the LED:

a. Set a breakpoint on a line within pitCh0Handler()


b. Go to the EmbSys Registers view, expand the SIUL2 module and scroll down to the GPDO register index which is accessed in the code. Double-click it to read the value. Expand it to see the individual bits.

c. Press Resume a few times to see the register value change



First of all. Great introductory. I wish I would have found this earlier. 

Second, all the example projects and this one gives me the error "No source available for "0x1000000" when I try to debug. 

Sometimes it will say "No source available for "(gdb[2].proc[42000].threadGroup[i1],gdb[2].proc[42000].OSthread[1]).thread[1].frame[0]" "

I am using the X - MPC574XG - MB with the MPC574XG-176DS with the USB Multilink interface debugger.

/*** The following is the Console output ***/

Connection from "" via
Copyright 2017 P&E Microcomputer Systems,Inc.
Command Line :C:\NXP\S32DS_Power_v2017.R1\eclipse\plugins\com.pemicro.debug.gdbjtag.ppc_1.7.2.201709281658\win32\pegdbserver_power_console -device=MPC5746B -startserver -singlesession -serverport=7224 -gdbmiport=6224 -interface=USBMULTILINK -speed=5000 -Ô


MPC574xB/C/D Device detected.
Target has been RESET and is active.
CMD>CM C:\NXP\S32DS_Power_v2017.R1\eclipse\plugins\com.pemicro.debug.gdbjtag.ppc_1.7.2.201709281658\win32\gdi\P&E\nxp_mpc5746b_1x32x736k_cflash.pcp

MPC574xB/C/D Device detected.

;version 1.06, 06/27/2017, Copyright P&E Microcomputer Systems, [5746C_2944k]

;device NXP, MPC5746B, 1x32x736k, desc=CFlash

;begin_cs device=$00F90000, length=$002F0000, ram=$40000000

Loading programming algorithm ...

WARNING - Selected .PCP file has been modified. CRC16 = $C167
Verifying object file CRC-16 to device ranges ...
block 00FA0000-00FA0003 ...
block 00FA0010-00FA0013 ...
block 01000000-01000129 ...
block 01001000-010010F3 ...
block 01002000-01002C0B ...
block 01002C10-0100780F ...
Checksum Verification Successful. (Cumulative CRC-16=$A72C)
Application verified in memory. No need to reprogram.


MPC574xB/C/D Device detected.
Target has been RESET and is active.

Starting reset script (C:\NXP\S32DS_Power_v2017.R1\eclipse\plugins\com.pemicro.debug.gdbjtag.ppc_1.7.2.201709281658\win32\gdi\P&E\s32e200_mpc574xc.mac) ...
REM This script is compatible with MPC574xC devices.
REM Clean GPRs to remove residual data after using algorithm
REM Initialize all of the Main SRAM - 512KB
Initializing RAM from $40000000 to $4007FFFF.

Reset script (C:\NXP\S32DS_Power_v2017.R1\eclipse\plugins\com.pemicro.debug.gdbjtag.ppc_1.7.2.201709281658\win32\gdi\P&E\s32e200_mpc574xc.mac) completed.

MPC574xB/C/D Device detected.

No ratings
Version history
Last update:
‎10-25-2017 07:31 AM
Updated by: