MPC5777C MCAL4.3 Dual Core Project Implementation

by: NXP Semiconductors

1. Introduction

This application note introduces the dual-core project implementation in MCAL4.3. This sample application is for the MPC5777C microcontroller with AUTOSAR MCAL4.3 version RTM1.0.0.

This application note provides an introduction about startup and link file modification to implement a dual-core project. It also provides the sample code in the software package accompanying this document.

The following table shows the abbreviations used throughout the document.

Table 1. Acronym and definition
Term/Acronym Definition
BAM Boot Assist Module
IVPR Interrupt vector prefix register

2. MCAL4.3 Startup and Link file

MCAL4.3 startup and link file is for one core; therefore, the startup and link file needs to be modified for two cores.

2.1. Dual core memory section

Flash_rsvd1 is used to store RCW, and flash_memory is used by core 0. Modify the link file to allocate flash_memory1 to store the core 1 startup code and fix the vector reset address as 0x00ED0000. This address also needs to be configured in EB tresos.

Note: This linker command file is to be used with the MPC5777C device only.

MEMORY {
/* 5777C Flash 8.0 MB 0x00800000 0x00FFFFFF */
 flash_rsvdl : ORIGIN = 0x00800000, LENGTH = 0x20
 /*flash_memory : ORIGIN = 0x00800020, LENGTH = 0x7CFFE0*/
 flash_memory : ORIGIN = 0x00800020, LENGTH = 0x6CFFE0
 flash_memoryl : ORIGIN = 0x00ED0000, LENGTH = 0x100000
 flash_vec : ORIGIN = 0x00FD0000, LENGTH = 0x010000
 flash_vec_corel : ORIGIN = 0x00FE0000, LENGTH = 0x010000
 flash_rsvd2 : ORIGIN = , LENGTH = 0
}

Figure 1. Memory for two core

The following figure shows the allocated stack for core 0, starting from address 0x4003EBC0. The core 1 stack address starts from 0x4003FBC0 and has a length of 4k.

/* 5777C SRAM 512 KB : 0x40000000 0x4007FFFF */
 ram_rsvdl : ORIGIN = 0x20000000, LENGTH = 0
 int_sram : ORIGIN = 0x40000000, LENGTH = 0x3EB60
 res_ram : ORIGIN = 0x4003EB60, LENGTH = 0x60
 iram_stack : ORIGIN = 0x4003EBCO, LENGTH = 0x1000
 iram_stack_corel : ORIGIN = 0x4003FBCO, LENGTH = 0x1000
 int_timers : ORIGIN = 0x40040BC0, LENGTH = 0x0340
 int_results : ORIGIN = 0x40040F00, LENGTH = 0x0100
 int_sram_no_cacheable : ORIGIN = 0x40041000, LENGTH = 0x3F000
 ram_rsvd2 : ORIGIN = , LENGTH = 0

Figure 2. Stack for core1

The following figure shows the allocated new section for core 1:

  • .text1: section for core 1 startup code
  • .isrvectbl_core1: section for core 1 interrupt vector table
  • .isrvectbl_core_corel: section for core1 core vector table (IVOR)
  • _IV_ADDR_core1: gets the flash_vec_corel address
  • _SP_INIT_core1: gets iram_stack_corel address
.textl : > flash_memoryl
.isrvectbl_corel : ALIGN (0x10000) : > flash_vec
.isrvectbl_core_corel : ALIGN (0x10000) : > flash_vec_corel
_IV_ADDR_corel = MEMADDR(flash_vec);
_IV_ADDR_corel = MEMADDR(flash_vec_corel);
_SP_INIT_corel = ADDR(iram_stack_corel) + SIZEOF(iram_stack_corel);
_SP_END_corel = ADDR(iram_stack_corel);
STACK_SIZE_corel = SIZEOF(iram_stack_corel);

Figure 3. Allocated new section for core 1

2.2. Dual core startup file

To place the startup code into its own section, use the GHS compiler keywords to set the core 1 startup code to the text1 section.

#pragma ghs section text=".textl"
void StartupCode_corel(void)
{
 ASM_KEYWORD (".globl _start1");
 ASM_KEYWORD (".globl startl");
 ASM_KEYWORD (".align 4");
 ASM_KEYWORD ("_start1:");
 ASM_KEYWORD ("start1:");
}
#pragma ghs section

Figure 4. Startup code for core 1

The following figure shows the IVPR register that needs to be initialized to the address of the interrupt vector table and exception vector handler. These handler addresses are provided as configuration parameters in link setting.

/* Initialize IVPR register to address of Interrupt Vector Table */
ASM_KEYWORD (" e_lis r5, IV_ADDR_corel@h ");
ASM_KEYWORD ("e_or2i r5, IV_ADDR_corel@l ");
ASM_KEYWORD (" mtIVPR r5");
ASM_KEYWORD ("se_mr r0, r31 ");

ASM_KEYWORD (" e_lis r5, IVORO_Handler_corel@h ");
ASM_KEYWORD (" e_or2i r5, IVORO_Handler_corel@l ");
ASM_KEYWORD("mtspr 400, r5 ");

ASM_KEYWORD (" e_lis r5, IVOR1_Handler_corel@h ");
ASM_KEYWORD (" e_or2i r5, IVOR1_Handler_corel@l ");
ASM_KEYWORD("mtspr 401, r5 ");

ASM_KEYWORD (" e_lis r5, IVOR2_Handler_corel@h ");
ASM_KEYWORD (" e_or2i r5, IVOR2_Handler_corel@l ");
ASM_KEYWORD("mtspr 402, r5 ");

ASM_KEYWORD (" e_lis r5, IVOR3_Handler_corel@h ");
ASM_KEYWORD (" e_or2i r5, IVOR3_Handler_corel@l ");
ASM_KEYWORD("mtspr 403, r5 ");

ASM_KEYWORD (" e_lis r5, IVOR4_Handler_corel@h ");
ASM_KEYWORD (" e_or2i r5, IVOR4_Handler_corel@l ");
ASM_KEYWORD("mtspr 404, r5 ");

Figure 5. Interrupt vector and exception handler initialization

The machine check and exception for core 1 should be enabled as shown in the following figure.

/* define MSR mask to enable Machine Check and Exception / IRQ */
ASM_KEYWORD(".equ MSR_Mask1, 0x00009000 ");
ASM_KEYWORD(" mfmsr r5 ");
ASM_KEYWORD (" e_lis r6, MSR_Mask1@h ");
ASM_KEYWORD (" e_or2i r6, MSR_Mask1@l ");
ASM_KEYWORD(" se_or r5, r6 ");
ASM_KEYWORD(" mtmsr r5 ");
ASM_KEYWORD (" se_isync");

Figure 6. Machine check and exception for core 1

Start-up code should initialize the user stack pointer for core 1, as shown in the following figure.

/*
* Autosar Guidance 3 The start-up code shall initialize the
* user stack pointer. The user stack pointer base address and
* the stack size are provided as configuration parameter or
* linker/locator setting.
*/
ASM_KEYWORD(" e_lis r1, SP_INIT_corel@h");
ASM_KEYWORD(" e_or2i r1, SP_INIT_corel@l");

Figure 7. Stack initialization for core 1

3. Core 0 and core 1 reset vector configuration

On the MPC577C device, the BAM occupies 16 KB of memory space, from 0xFFFF_C000 to 0xFFFF_FFFF. The actual code size of the BAM program is less than 4 KB and starts at 0xFFFF_F000, repeating itself after every 4 KB in the BAM address space. BAM program execution starts at the reset vector from address 0xFFFF_FFFС. The BAM exits to user code at 0xFFFF_FFF8. The last instruction executed by BAM is a BLR. The link register is pre-loaded with the user application start address. The value of the start address depends on the boot mode:

The following table shows the BAM address map.

Table 2. BAM memory map
Address Description
0xFFFF_C000 - 0xFFFF_EFFF BAM program mirrored
0xFFFF_F000 - 0xFFFF_FFFF BAM program
0xFFFF_FFFC MCU reset vector
0xFFFF_FFF8 BAM last executed instruction

4. Compile and testing

4.1. Compiling GHS

The test hardware is the MPC5777C EVB. Compiler GHS version is compiler 2019.5.4 (it is recommended to update to the latest version). EB tresos version is 25.1, and the MCAL package version is MPC5777C MCAL4.3 1.0.0.

Open the build folder as shown in the following figure.

Figure 10. Sample code build folder

The launch.bat file contains configuration for TRESOS_DIR, MAKE_DIR, GHS_DIR, and PLUGINS_DIR. It also specifies the TRESOS_WORKSPACE_DIR.

To build the sample, execute the following command to run launch.bat:

C:\Windows\System32\cmd.exe

C:\Work_Material\software\vds-mpc5777c-mcal4.3\vds-mpc5777c-mca14.3\MPC5777C_MCAL4_3_RTM_1_0_0_Sample_Application\eclipse\plugins\PlatformIntegration_TS_T2D41M10IORO\build\launch.bat

Figure 12. Build command

The object files and linker output file (PlatformIntegration.elf) will be generated in the /bin subdirectory. Open the cmm folder and run the smp_demo.cmm script using LAUTERBACH debugger and debug the sample application code.

4.2. Test result

This sample application was tested on the MPC5777C EVB. Core 0 is running the MCAN transmission, and core 1 is running the CAN transmission.

Figure 13. MPC5777C EVB board

Figure 14. MCAN sample transmission in core0

Figure 15. CAN transmission in core1

5. References

PDF preview unavailable. Download the PDF instead.

AN13063 Microsoft Word for Office 365

Related Documents

Preview MPC5777C Mask Set Errata for Mask 3N45H
This document details errata and provides workarounds for the MPC5777C microcontroller using mask set 3N45H. It covers various modules including CJTAG, CMU, CRC, DECFIL, DSPI, EBI, eMIOS, EQADC, eSCI, ETPU2, eTPU, FCCU, FEC, FLASH, FlexCAN, INTC, JTAGC, LFAST, MCAN, MPC5777C, NPC, NZxC3, PADRING, PASS, PMC, PSI5, REACM, SDADC, SENT, SIU, SPI, STCU, SWT, TDM, and XBIC.
Preview MCUXpresso IDE User Guide - NXP Semiconductors
Comprehensive user guide for NXP Semiconductors' MCUXpresso IDE, detailing its features, development environment, debugging capabilities, SDK integration, and tools for embedded software development on ARM Cortex-M microcontrollers.
Preview NXP S32K1xx Series Cookbook: Software Examples and Startup Code
Explore software examples and essential startup code for NXP's S32K1xx series microcontrollers. This cookbook guides users through microcontroller features using NXP's S32 Design Studio.
Preview NXP Semiconductors N.V. 2024 Annual Report
Explore the NXP Semiconductors N.V. 2024 Annual Report for comprehensive insights into financial results, business operations, market strategies, governance, and future outlook. Discover NXP's performance across automotive, industrial, mobile, and communication sectors.
Preview i.MX RT685 Evaluation Board User Manual
User manual for the NXP i.MX RT685 Evaluation Board (MIMXRT685-EVK), detailing its features, layout, setup, peripherals, and troubleshooting.
Preview NXP LPC54S60x/LPC5460x Microcontroller User Manual
Comprehensive user manual for NXP's LPC54S60x and LPC5460x microcontrollers, detailing ARM Cortex-M4 architecture, peripherals, memory maps, clocking, and system configuration.
Preview TJA1443 High-Speed CAN Transceiver with Sleep Mode | NXP Semiconductors Datasheet
Explore the NXP Semiconductors TJA1443, a high-speed CAN transceiver supporting CAN FD up to 5 Mbit/s. This datasheet details its low-power modes, wake-up features, fail-safe operation, and automotive qualifications for embedded systems.
Preview NXP JN5189(T)/JN5188(T) User Manual: Arm Cortex-M4 Wireless Microcontrollers
Comprehensive user manual for NXP's JN5189(T) and JN5188(T) ultra-low power wireless microcontrollers featuring Arm Cortex-M4. Details features, architecture, pinouts, power management, and Zigbee/Thread support for IoT applications.