【简介】
S32K3芯片是一颗支持ASILD的芯片,CPU是支持Lockstep和Decoupled 模式本次我们使用S32K388芯片来熟悉了解对应配置。S32K388 在Lockstep 模式时CORE0 和 CORE1 是作为lockstep核使用,当前是否是Lockstep状态可以从 DCMROF19 寄存器获取。

本地的388芯片debug 读取bit29 为lockstep 模式。

LockStep 的配置可以通过DCF来进行配置,默认状态未lockstep 状态,芯片启动时回加载DCF中的配置来确定是否是lockstep模式启动。

DCF record 是在utest 区域中划分了一段地址空间进行管理,以下是每条record 的配置结构,在DCF的配置中可以包含多条配置结构。

以下是DCF record 在UTEST 区域中的数据的管理方式,数据的开始是一个start 结构,然后跟着多条配置信息的方式,每条配置由CS+address的防暑进行管理,同样的CS+addrress配置后面的数据回覆盖前面的数据。


以下未UTEST 区域中DCF record 区域的地址配置偏移为0x700

本地读取的数据如下

如下的数据为当前为lockstep 模式,在后面加一条配置信息配置为Decoupled 就会切换到Decoupled 模式启动

我们按照上面的record 的数据机构配置为00000100 00100006即可实现将当前的lockstep 的配置切换为Decoupled 的模式。
编写如下代码切换到Decoupled
/*==================================================================================================
* Project : RTD AUTOSAR 4.9
* Platform : CORTEXM
* Peripheral : S32K3XX
* Dependencies : none
*
* Autosar Version : 4.9.0
* Autosar Revision : ASR_REL_4_9_REV_0000
* Autosar Conf.Variant :
* SW Version : 7.0.1
* Build Version : S32K3_RTD_7_0_1_D2602_ASR_REL_4_9_REV_0000_20260206
*
* Copyright 2020 - 2026 NXP
*
* NXP Confidential and Proprietary. This software is owned or controlled by NXP and may only be
* used strictly in accordance with the applicable license terms. By expressly
* accepting such terms or by downloading, installing, activating and/or otherwise
* using the software, you are agreeing that you have read, and that you agree to
* comply with and are bound by, such license terms. If you do not agree to be
* bound by the applicable license terms, then you may not retain, install,
* activate or otherwise use the software.
==================================================================================================*/
/**
* @file main.c
*
* @addtogroup main_module main module documentation
* @{
*/
#ifdef __cplusplus
extern "C"{
#endif
/*==================================================================================================
* INCLUDE FILES
* 1) system and project includes
* 2) needed interfaces from external units
* 3) internal and external interfaces from this unit
==================================================================================================*/
#include "Clock_Ip.h"
#include "C40_Ip.h"
#include "C40_Ip_Types.h"
/*==================================================================================================
* LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
==================================================================================================*/
/*==================================================================================================
* LOCAL MACROS
==================================================================================================*/
#define FLS_MASTER_ID 0U
#define DCF_SIZE 2U
#define DCF_SIZE_BYTES 8U
#define DCF_ADDR 0x1B000770U
#define UTEST_SECTOR C40_UTEST_ARRAY_0_S000
/*==================================================================================================
* LOCAL CONSTANTS
==================================================================================================*/
/*==================================================================================================
* LOCAL VARIABLES
==================================================================================================*/
uint32_t DCF_record[DCF_SIZE];
/*==================================================================================================
* GLOBAL CONSTANTS
==================================================================================================*/
/*==================================================================================================
* GLOBAL VARIABLES
==================================================================================================*/
/*==================================================================================================
* LOCAL FUNCTION PROTOTYPES
==================================================================================================*/
/*==================================================================================================
* MAIN FUNCTIONS
==================================================================================================*/
int main(void)
{
/* New DCF record */
DCF_record[0] = 0x00000100; /* DCF Data Word, LOCKSTEP = 0 */
DCF_record[1] = 0x00100006; /* DCF Control Word */
/* Initialize clock */
Clock_Ip_StatusType ClockStatus;
ClockStatus = Clock_Ip_Init(&Clock_Ip_aClockConfig[0]);
if(CLOCK_IP_ERROR == ClockStatus){}
/* Initialize C40_Ip */
volatile C40_Ip_StatusType C40Status_lock;
volatile C40_Ip_StatusType C40Status_write;
C40_Ip_Init(&C40_Ip_InitCfg);
/* If DCF_ADDR is erased */
if((*(uint32_t*)DCF_ADDR) == 0xFFFFFFFF)
{
/* Unlock sector if needed */
if (C40_IP_STATUS_SECTOR_PROTECTED == C40_Ip_GetLock(UTEST_SECTOR))
{
C40Status_lock = C40_Ip_ClearLock(UTEST_SECTOR, FLS_MASTER_ID);
while(C40_IP_STATUS_SUCCESS != C40Status_lock);
}
/* Write DCF */
C40_Ip_MainInterfaceWrite(DCF_ADDR, DCF_SIZE_BYTES, (uint8_t*)DCF_record, FLS_MASTER_ID);
do
{
C40Status_write = C40_Ip_MainInterfaceWriteStatus();
}
while(C40_IP_STATUS_BUSY == C40Status_write);
while(C40_IP_STATUS_SUCCESS != C40Status_write);
}
else
{
__asm__("BKPT");
/* Offset DCF_ADDR */
}
while(1){
}
return (0U);
}
#ifdef __cplusplus
}
#endif
/** @} */
此时读取状态已经切换为 Decoupled 模式了。

我要赚赏金
