s32k312 + fs26 control problem

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

s32k312 + fs26 control problem

Jump to solution
3,453 Views
NewbieNerd
Contributor III

Hello S32K3 team!
I am currently attempting to control FS26 on the S32K312EVB.

  1. Whenever I query 'FS_STATE', 'REG_CORRUPT' is always in a high state. The calculations for all init_register and init_not_register values are consistent. Please inform me how to reset this state.

  2. Even after successfully attempting 'WD_Refresh', it does not switch to 'Normal state' and remains in 'Safety Outputs not released' status. Is this related to issue number 1?

  3. The system resets when I input the debug_mode_exit value. What could be the issue?

Regard

0 Kudos
Reply
1 Solution
3,374 Views
guoweisun
NXP TechSupport
NXP TechSupport

If the FLT_ERR_CNT is 0,you can  release FS0B no problem then enter into normal mode.

View solution in original post

0 Kudos
Reply
24 Replies
300 Views
Akhil1
Contributor I

Hello @NewbieNerd ,

Did you use RTD 2.0.3 or 3.0.0 version, can you share the screenshot of main.c , so that it will be helpful for me.

I got struck in this

 

0 Kudos
Reply
297 Views
NewbieNerd
Contributor III

hi akhil1


I'm using RTD 3.0.0 in now. However, it is expected that 2.0.3 will not be any different.

here is my code

/*==================================================================================================
*   Project              : RTD AUTOSAR 4.7
*   Platform             : CORTEXM
*   Peripheral           : S32K3XX
*   Dependencies         : none
*
*   Autosar Version      : 4.7.0
*   Autosar Revision     : ASR_REL_4_7_REV_0000
*   Autosar Conf.Variant :
*   SW Version           : 3.0.0
*   Build Version        : S32K3_RTD_3_0_0_D2303_ASR_REL_4_7_REV_0000_20230331
*
*   Copyright 2020 - 2023 NXP Semiconductors
*
*   NXP Confidential. 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
*   @{
*/

/* Including necessary configuration files. */
#include "Mcal.h"
#include "Port.h"
#include "Platform.h"
#include "Mcu.h"
#include "CDD_Uart.h"
#include "Dio.h"
#include "Dio_Ipw.h"
#include "Spi.h"
#include "Gpt.h"
#include "Icu.h"
#include "EcuM.h"
#include "CDD_Sbc_fs26.h"

#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>

#define UART_LPUART_INTERNAL_CHANNEL 0
#define BUFFER_SIZE 512

static char s_buffer[BUFFER_SIZE];
uint32 T_timeout = 0xFFFFFF;
volatile Uart_StatusType Uart_TransmitStatus = UART_STATUS_TIMEOUT;

volatile int exit_code = 0;
/* User includes */

static boolean bWdRefresh = FALSE;

void UART_Print(const char *fmt, ...)
{
    uint32 tempByte = 0;
    __VALIST ap;

    T_timeout = 0xFCF;
    va_start(ap, fmt);
    (void)vsnprintf(s_buffer, BUFFER_SIZE, fmt, ap);
    //(void)snprintf(s_buffer, BUFFER_SIZE, fmt, ap);
    va_end(ap);

    s_buffer[BUFFER_SIZE - 1] = '\0';
    Uart_AsyncSend(UART_LPUART_INTERNAL_CHANNEL, (uint8_t *)s_buffer, strlen(s_buffer));
    do
    {
        Uart_TransmitStatus = Uart_GetStatus(UART_LPUART_INTERNAL_CHANNEL, &tempByte, UART_SEND);
    } while (UART_STATUS_NO_ERROR != Uart_TransmitStatus && 0 < T_timeout--);

    //    while(Uart_GetStatus(UART_LPUART_INTERNAL_CHANNEL, &tempByte, UART_SEND) == UART_STATUS_OPERATION_ONGOING);
}

void FS26_Cbk_GptNotification0()
{
    if(bWdRefresh == TRUE)
    {
        Sbc_fs26_WdRefresh();
    }
   Gpt_StopTimer(0);
   Gpt_StartTimer(0, 10000U);
   //UART_Print("Gpt Noti\n");
}

/*!
  \brief The main function for the project.
  \details The startup initialization sequence is the following:
 * - startup asm routine
 * - main()
*/
int main(void)
{
    /* Write your code here */
    boolean bPass = TRUE;
    Sbc_fs26_RxFrameType xRxData = {0};  /* Received data structure. */
    Std_ReturnType eReturnValue = E_OK; /* Error status. */
    uint8 errorCounter = 0xFF;          /* Error counter*/
    uint16 u16Answer = 0;
    uint8 u8MaskedValue = 0U;
    uint32 u32DelayCount = 0x0;
    uint8 u8SWInput = 0;
    uint32 u32PrintCount = 0x0;

    Sbc_fs26_WuSrcType wkSrc ={FALSE, TRUE, FALSE, FALSE, FALSE, FALSE};
    Sbc_fs26_WuPolType wkPol = {FALSE, FALSE, FALSE, FALSE};

    /* Write your code here */
    /* Initialize Mcu module */
    Mcu_Init(NULL_PTR);
    /* Initialize Mcu Clock */
    Mcu_InitClock(McuClockSettingConfig_0);
#if (MCU_NO_PLL == STD_OFF)
    /* Wait until PLL is locked */
    while (Mcu_GetPllStatus() != MCU_PLL_LOCKED)
    {
    }
    /* Use PLL clock */
    Mcu_DistributePllClock();
#endif
    Mcu_SetMode(0);

    /* Call OsIf timmer */
    OsIf_Init(NULL_PTR);

    /* Platform initialization */
    Platform_Init(NULL_PTR);

    /* Port initialization */
    Port_Init(NULL_PTR);

    /*UART initialization*/
    Uart_Init(NULL_PTR);

    /* SPI initialization */
    Spi_Init(NULL_PTR);

    /* GPT initialization */
    Gpt_Init(NULL_PTR);

    /* ICU initialization */
    Icu_Init(NULL_PTR);

    UART_Print("\tInit_drivers\n");

    Mcu_ResetType resetReason = Mcu_GetResetReason();
    UART_Print("\tMcu Reset Reason : %d\n", (uint8)resetReason);

    /*start wdg for fs26 wd Sbc_fs26_WdRefrsh*/
    Gpt_EnableNotification(0);
    UART_Print("\tGPT Started\n");
    Gpt_StartTimer(0, 10000U);

    /* Driver and device initialization. */
    eReturnValue = Sbc_fs26_Init(NULL_PTR);
    if(eReturnValue != E_OK)
    {
        bPass = FALSE;
    }

    /*fs26 go to normal mode*/
    bPass = FALSE;
    do
    {
        UART_Print("--------------Try FS26 Device Initialization--------------\n");
        eReturnValue = Sbc_fs26_InitDevice();
        Sbc_fs26_ReadRegister(TRUE, SBC_FS26_FS_STATES_ADDR, &xRxData);
        if (0xb == (xRxData.u16ReadData & SBC_FS26_FS_FS_STATES_MASK))
        {
            UART_Print("--------Success FS26 Device Initialization------------\n");
            Sbc_fs26_WdRefresh();
            bPass = TRUE;
            bWdRefresh = TRUE;
        }
        else
        {
            // Sbc_fs26_WriteRegister(TRUE, SBC_FS26_FS_WD_TOKEN_ADDR, 0x5AB2);
            bWdRefresh = FALSE;
        }
    } while (bPass == FALSE);

    Sbc_fs26_ReadRegister(TRUE, SBC_FS26_FS_STATES_ADDR, &xRxData);
    if (SBC_FS26_FS_DBG_MODE_DEBUG == (xRxData.u16ReadData & SBC_FS26_FS_DBG_MODE_MASK))
    {
        UART_Print("\tAfter Init, FS26 - Exit DEBUG MODE\n");
        Sbc_fs26_WriteRegister(TRUE, SBC_FS26_FS_STATES_ADDR, SBC_FS26_FS_EXIT_DBG_MODE_MASK);
        Sbc_fs26_ReadRegister(TRUE, SBC_FS26_FS_STATES_ADDR, &xRxData);
    }

    do
    {
        if (u32DelayCount != 0 && (u32DelayCount % 0x112A880 == 0))
        {
            u32PrintCount += 1;
            UART_Print("\t SW Waiting - %d\n", u32PrintCount);
            u32DelayCount = 0;
        }
        else
        {
            // UART_Print("\t SW Input Waiting - 3, %d\n", u32DelayCount);
            u32DelayCount++;
        }
        u8SWInput = Dio_ReadChannel(DioConf_DioChannel_USER_SW0);
    } while (u8SWInput != STD_HIGH);

    UART_Print("\t SW Input Confirmed\n\n");

    Sbc_fs26_ReadRegister(TRUE, SBC_FS26_FS_STATES_ADDR, &xRxData);
    if (0xb == (xRxData.u16ReadData & SBC_FS26_FS_FS_STATES_MASK))
    {
        UART_Print("\tFS26 Is Normal Mode, And Go to LPOff Mode\n");
        Sbc_fs26_SetWakeup(wkSrc, wkPol);
        // Sbc_fs26_SetOperatingMode(SBC_FS26_OPMODE_STANDBY);
        // Sbc_fs26_SetOperatingMode(SBC_FS26_OPMODE_LPOFF);
        Icu_EnableEdgeDetection(0);
        Icu_EnableNotification(0);
        Icu_EnableWakeup(0);

        Icu_SetMode(ICU_MODE_SLEEP);

        UART_Print("\tGo to Standby or LPOFF\n");
        /* Go to pre LPOFF from Normal. */
        Sbc_fs26_WriteRegister(TRUE, SBC_FS26_FS_LP_REQ_ADDR, SBC_FS26_OPMODE_LPOFF);
        /* Go to LPOFF from pre LPOFF. */
        Sbc_fs26_WriteRegister(TRUE, SBC_FS26_FS_LP_REQ_ADDR, SBC_FS26_FS_FS_LP_REQ_LPOFF);
       
    }
}

/** @} */
 
Regard

 

0 Kudos
Reply
281 Views
Akhil1
Contributor I

Hi @NewbieNerd ,

Thank you for sharing, But is there any possibility to share the project file...because for 2.0.3 the code is different with respect to 3.0.0 

like RTD files...Sbc_fs26_InitDevice function ...there are many changes in code

I am confusing, can you please provide me?

0 Kudos
Reply
274 Views
Akhil1
Contributor I

Hi @NewbieNerd ,

Did you use S32K312 board for watchdog refresh?

0 Kudos
Reply