Hello,
I'm using a custom board with the new S32K311 microcontroller. I want to test the external oscillator of 16 MHz, and if I debug an example project it works fine.
The problem is when I run the program without debugging, here the microcontroller runs for ~9 seconds, and then it shutdowns.
The PLL clock is configured as CORE_CLK, and I tried with different frequencies but it didn't work. When I configure the FIRC as CORE_CLK, it works fine.
PLL tested frequencies: 120 Hz, 48Hz
SDK: PlatformSDK_S32K3_S32K311_M7
SDK version: 3.0.0
RTD: S32K3XX AUTOSAR 4.4 - R21-11 RTD 3.0.0 D2303
Hi @simonjuanr
Which example are you using? Could you share all the modifications made to the example? Does S32DS show a hard fault or any error? Does this happen with any other examples that use the external clock?
B.R
Vane
Hello Vane,
I'm not using any example as I couldn't find any for this micro. I can share with you my test program:
/*==================================================================================================
* 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 "Pit_Ip.h"
#include "Clock_Ip.h"
#include "IntCtrl_Ip.h"
#include "Siul2_Port_Ip.h"
#include "Siul2_Dio_Ip.h"
/* PIT instance used - 0 */
#define PIT_INST_0 0U
/* PIT Channel used - 0 */
#define CH_0 0U
/* PIT time-out period - equivalent to 1s */
#define PIT_PERIOD 40000
uint8_t toggle = 0u;
void PitNotification(void);
void PitNotification(void)
{
toggle = 1U;
}
/*!
\brief The main function for the project.
\details The startup initialization sequence is the following:
* - startup asm routine
* - main()
*/
void main(void)
{
Clock_Ip_StatusType ClockStatus = Clock_Ip_Init(&Clock_Ip_aClockConfig[0]);
uint8_t val = 0u;
/* set PIT 0 interrupt */
IntCtrl_Ip_Init(&IntCtrlConfig_0);
IntCtrl_Ip_EnableIrq(PIT0_IRQn);
/* Initialize PIT instance 0 - Channel 0 */
Pit_Ip_Init(PIT_INST_0, &PIT_0_InitConfig_PB);
/* Initialize channel 0 */
Pit_Ip_InitChannel(PIT_INST_0, PIT_0_CH_0);
/* Enable channel interrupt PIT_0 - CH_0 */
Pit_Ip_EnableChannelInterrupt(PIT_INST_0, CH_0);
/* Start channel CH_0 */
Pit_Ip_StartChannel(PIT_INST_0, CH_0, PIT_PERIOD);
Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);
/* More GPIO configuration */
while(1)
{
if (toggle)
{
Siul2_Dio_Ip_WritePin(STEP_PORT, STEP_PIN, val);
if (val == 0u)
{
val = 1u;
}
else
{
val = 0u;
}
toggle = 0u;
}
}
}
/** @} */
Where I basically toggle one GPIO (PTE9).
The point here is that when I attach the debugger and run the program, it works correctly. The problem is when I try to run it without the debugger.
I also couldn't find any example that uses the external oscillator.
Hi @simonjuanr
Thank you for sharing your code.
Could you also share the configurations made in Config Tools? To be able to be in the same context as you.
Hi Vane. Yes, sure.
On the peripheral view:
(There's more GPIOs configured, as I'm spinning a stepper motor and they are needed to configure the stepper driver, but this is the one I'm toggling)
Clocks are set to the default values, and in the Pins view, the pin PTE9 is configured as output.
Hi @simonjuanr
I tested the code on an S32K312EVB-Q172 because there are no S32K311EVBs available.
The code works without any problem. I want to verify that this is not cause by the IDE or a hardware problem.
Could you try deleting S32DS and reinstalling it just with the packages for S32K3 devices as S32K3_M27X Real-Time Drivers Version 3.0.0 P07 and S32 Design Studio 3.5.8 Development Package with support for S32K3xx devices?
Also, could you verify the JTAG and TRACE interface connections and the EXTAL and XTAL pins, as recommended in the Hardware Design Guidelines for S32K3xx Microcontrollers?