2405600_en-US

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

2405600_en-US

2405600_en-US

16MHz external crystal not working on the S32K314HMS custom board

Hi,

I am facing an issue with an external crystal of 16MHz not working with S32K314HMS custom board. I am using a build created from S32 Design Studio for S32 Platform Version: 3.6.9 Build id: 260624. I am using raw code to test the board function, as shown below in main.c:

#include 
/* Corrected Raw Hardware Register Addresses for S32K314 */
#define SIUL2_MSCR_PTB5           (*(volatile uint32_t*)(0x40290294U))
#define MC_CGM_CLKOUT_CNTRL       (*(volatile uint32_t*)(0x402D4000U))

/* --- CORRECTED FXOSC REAL ADDRESSES --- */
#define FXOSC_CTRL_REG            (*(volatile uint32_t*)(0x40288000U)) /* Corrected from 402D4000 */
#define FXOSC_STAT_REG            (*(volatile uint32_t*)(0x40288004U)) /* Corrected from 402D4004 */

volatile uint32_t rawTimeoutCounter = 0;
volatile uint32_t crystalStableResult = 0;

int main(void)
{
    /* 1. RAW PIN SETUP: Configure PTB5 as a High-Drive Output mapped to CLKOUT */
    SIUL2_MSCR_PTB5 = (5U << 0) | (1U << 21) | (1U << 19);

    /* 2. RAW CLOCK ROUTING: Route the Raw FXOSC clock directly to the CLKOUT hardware block */
    MC_CGM_CLKOUT_CNTRL = (1U << 24) | (0U << 16); /* Source = FXOSC_CLK, Divider = 1, Enable = 1 */

    /* 3. RAW HARDWARE KICKSTART: Power on the External Crystal (FXOSC) analog circuitry */
    FXOSC_CTRL_REG |= 0x01U;

    /* 4. NON-BLOCKING SOFTWARE POLL
       We read the raw hardware status register. If a crystal is physically
       oscillating, the status register will flip a hardware bit or report a non-zero value. */
    for (rawTimeoutCounter = 0; rawTimeoutCounter < 800000U; rawTimeoutCounter++)
    {
        /* Check if the FXOSC status register reports it is locked and stable (Bit 31) */
        if ((FXOSC_STAT_REG & 0x80000000U) != 0U)
        {
            crystalStableResult = 1; /* HW SUCCESS: Crystal is alive and shaking! */
            break;
        }
    }

    /* 5. PASS / FAIL EVALUATION PADS */
    if (crystalStableResult == 1)
    {
        /* --- CRYSTAL HARDWARE PASSED --- */
        for (;;)
        {
            __asm("NOP"); /* Put a breakpoint here for success */
        }
    }
    else
    {
        /* --- CRYSTAL HARDWARE FAILED --- */
        for (;;)
        {
            __asm("NOP"); /* Put a breakpoint here for a safe failure catch */
        }
    }

    return 0;
}

I am attaching the board schematic for your reference.

board_schematic.pngboard_schematic.pngboard_schematic.png

Also attaching the .mex configuration for your reference.

Re: 16MHz external crystal not working on the S32K314HMS custom board

Hello @sksingh4476 ,

a 16 MHz crystal is within the supported FXOSC crystal frequency range for the S32K3 family, so the crystal frequency itself should not be the issue. However, from the raw code snippet it is not clear whether the complete FXOSC configuration is being applied. In particular, please check the FXOSC gain/transconductance setting (GM_SEL). In crystal mode, GM_SEL = 0000b should not be used, because this corresponds to zero transconductance and the oscillator may not start or become stable.

Regarding the mex file: The generated clock initialization code must be called by the application. If the test code bypasses the generated RTD initialization and writes only a few registers manually, then all mandatory FXOSC settings, including GM_SEL, must also be configured manually.

I would recommend first creating any standard S32DS/RTD example project and configuring the FXOSC through the Clock Configuration tool. Please verify whether the external crystal starts correctly with the generated RTD clock initialization code. This is a better baseline than starting directly with a minimal raw-register test, because the generated configuration should include all required FXOSC settings, including the oscillator mode and gain configuration.

If the standard example works, you can then compare the generated FXOSC register values with your minimal code and gradually reduce the code to the smallest required sequence. If the standard example does not work either, then the next step should be to check the hardware side, especially the crystal parameters, ESR, load capacitors including PCB stray capacitance, layout around EXTAL/XTAL, and the gain margin calculation. The datasheet specifies the oscillator build-up condition using gmXOSC > 5 * gm_crit, so the selected crystal and external components should be verified against this requirement.

Best regards,

Pavel

タグ(1)
評価なし
バージョン履歴
最終更新日:
昨日
更新者: