<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Enabling FIRC Clock on S32K396 in Low-Level Programming in S32K</title>
    <link>https://community.nxp.com/t5/S32K/Enabling-FIRC-Clock-on-S32K396-in-Low-Level-Programming/m-p/2324432#M57033</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I am working with the S32K396 board and trying to enable the FIRC clock using low-level programming. However, I have found that there is limited information available, and I haven't had much success.&lt;/P&gt;&lt;P&gt;My goal is to enable this clock using the MC_ME and MC_CGM modules, but I haven't been able to make it work properly. I have been referring to the Reference Manual, and while I selected a suitable MUX, I'm not sure if the registers I’m using are correct.&lt;/P&gt;&lt;P&gt;Has anyone worked with low-level programming on the S32K396?&lt;/P&gt;&lt;P&gt;I’ve attached my main code for review. My plan is to first enable the FIRC clock and then proceed with configuring the PLL and FXOSC.&lt;/P&gt;&lt;P&gt;#include &amp;lt;stdint.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/P&gt;&lt;P&gt;#define PORT_WRITE32(address, value) (*(volatile uint32_t *)(address) = (value))&lt;BR /&gt;#define PORT_WRITE8(address, value) (*(volatile uint8_t *)(address) = (value))&lt;BR /&gt;#define PORT_READ32(address) (*(volatile uint32_t *)(address))&lt;/P&gt;&lt;P&gt;// Base addresses for the registers (these should be adjusted based on your MCU documentation)&lt;BR /&gt;#define MC_CGM_BASE 0x402D8000U // Base address of the Clock Generation Module (MC_CGM)&lt;BR /&gt;#define MC_ME_BASE 0x402DC000U // Base address of the Clock Management Module (MC_ME)&lt;BR /&gt;#define SIUL2_BASE 0x40290000U // Base address of the SIUL2 for GPIO&lt;/P&gt;&lt;P&gt;// Registers of the MC_CGM (Clock Generation Module)&lt;BR /&gt;#define MC_CGM_MUX_6_CSC (MC_CGM_BASE + 0x480U)&lt;BR /&gt;#define MC_CGM_MUX_6_CSS (MC_CGM_BASE + 0x484U)&lt;BR /&gt;#define MC_CGM_MUX_6_DC_0 (MC_CGM_BASE + 0x488U)&lt;/P&gt;&lt;P&gt;// Registers of the MC_ME (Clock Management Module)&lt;BR /&gt;#define MC_ME_PRTN0_COFB1_CLKEN (MC_ME_BASE + 0x134U) //0x402DC134&lt;BR /&gt;#define MC_ME_PRTN0_PUPD (MC_ME_BASE + 0x104U) //0x402DC104&lt;BR /&gt;#define MC_ME_CTL_KEY (MC_ME_BASE + 0x000U) //0x402DC000&lt;BR /&gt;#define MC_ME_PRTN0_STAT (MC_ME_BASE + 0x108U) //0x402DC108&lt;BR /&gt;#define MC_ME_GS (MC_ME_BASE + 0x008U) //0x402DC008&lt;BR /&gt;#define MC_ME_PRTN0_PCONF (MC_ME_BASE + 0x100U) //0x402DC100&lt;BR /&gt;#define MC_ME_PRTN0_COFB1_STAT (MC_ME_BASE + 0x114U) //0x402DC114&lt;/P&gt;&lt;P&gt;#define MC_ME_KEY 0x5AF0U&lt;BR /&gt;#define MC_ME_INVKEY 0xA50FU&lt;/P&gt;&lt;P&gt;// Registers of the SIUL2 (GPIO Control)&lt;BR /&gt;#define SIUL2_MSCR231 0x402905DC&lt;BR /&gt;#define SIUL2_GPDO231 0x402913E4&lt;/P&gt;&lt;P&gt;#define asm __asm__&lt;/P&gt;&lt;P&gt;// Initialize the clock using direct register access&lt;BR /&gt;void CLOCK_InitFIRC(void)&lt;BR /&gt;{&lt;BR /&gt;// Enable FIRC&lt;BR /&gt;uint32_t temp;&lt;BR /&gt;temp = PORT_READ32(MC_ME_PRTN0_COFB1_STAT); // Read current status&lt;BR /&gt;if ((temp &amp;amp; (1 &amp;lt;&amp;lt; 5)) == 0) {&lt;BR /&gt;PORT_WRITE32(MC_ME_PRTN0_COFB1_CLKEN, (1 &amp;lt;&amp;lt; 1)); // Enable FIRC&lt;BR /&gt;PORT_WRITE32(MC_ME_PRTN0_PCONF, (1 &amp;lt;&amp;lt; 0)); // Enable FIRC&lt;BR /&gt;PORT_WRITE32(MC_ME_PRTN0_PUPD, (1 &amp;lt;&amp;lt; 1)); // Enable update&lt;BR /&gt;PORT_WRITE32(MC_ME_CTL_KEY, MC_ME_KEY); // Unlock control register&lt;BR /&gt;PORT_WRITE32(MC_ME_CTL_KEY, ~MC_ME_KEY); // Lock control register&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Wait for FIRC stabilization&lt;BR /&gt;do {&lt;BR /&gt;temp = PORT_READ32(MC_CGM_MUX_6_CSS); // Read the current clock source selection&lt;BR /&gt;} while ((temp &amp;amp; 0x0F) != 0x0); // Check if FIRC is selected (FIRC should have 0x0)&lt;/P&gt;&lt;P&gt;// Configure MUX6 to use FIRC as the clock source&lt;BR /&gt;PORT_WRITE32(MC_CGM_MUX_6_CSC, 0x0); // Select FIRC as clock source for MUX6&lt;BR /&gt;PORT_WRITE32(MC_CGM_MUX_6_DC_0, 0x0); // Set divisor to 1 (no division)&lt;/P&gt;&lt;P&gt;// Check the status of the clock&lt;BR /&gt;uint32_t status_clk = PORT_READ32(MC_CGM_MUX_6_CSS); // Read current clock status&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt;// Initialize the clock&lt;BR /&gt;CLOCK_InitFIRC();&lt;/P&gt;&lt;P&gt;// Initialize the GPIO for the LED&lt;BR /&gt;PORT_WRITE32(SIUL2_MSCR231, 0x200000);&lt;/P&gt;&lt;P&gt;while(1)&lt;BR /&gt;{&lt;BR /&gt;PORT_WRITE8(SIUL2_GPDO231, 0x1);&lt;BR /&gt;for(uint32_t i = 0; i &amp;lt; 20e6; i++)&lt;BR /&gt;{&lt;BR /&gt;asm("nop");&lt;BR /&gt;}&lt;BR /&gt;PORT_WRITE8(SIUL2_GPDO231, 0x0);&lt;BR /&gt;for(uint32_t i = 0; i &amp;lt; 20e6; i++)&lt;BR /&gt;{&lt;BR /&gt;asm("nop");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Any help or suggestions would be greatly appreciated.&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
    <pubDate>Fri, 27 Feb 2026 14:12:31 GMT</pubDate>
    <dc:creator>Jesusear18</dc:creator>
    <dc:date>2026-02-27T14:12:31Z</dc:date>
    <item>
      <title>Enabling FIRC Clock on S32K396 in Low-Level Programming</title>
      <link>https://community.nxp.com/t5/S32K/Enabling-FIRC-Clock-on-S32K396-in-Low-Level-Programming/m-p/2324432#M57033</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I am working with the S32K396 board and trying to enable the FIRC clock using low-level programming. However, I have found that there is limited information available, and I haven't had much success.&lt;/P&gt;&lt;P&gt;My goal is to enable this clock using the MC_ME and MC_CGM modules, but I haven't been able to make it work properly. I have been referring to the Reference Manual, and while I selected a suitable MUX, I'm not sure if the registers I’m using are correct.&lt;/P&gt;&lt;P&gt;Has anyone worked with low-level programming on the S32K396?&lt;/P&gt;&lt;P&gt;I’ve attached my main code for review. My plan is to first enable the FIRC clock and then proceed with configuring the PLL and FXOSC.&lt;/P&gt;&lt;P&gt;#include &amp;lt;stdint.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/P&gt;&lt;P&gt;#define PORT_WRITE32(address, value) (*(volatile uint32_t *)(address) = (value))&lt;BR /&gt;#define PORT_WRITE8(address, value) (*(volatile uint8_t *)(address) = (value))&lt;BR /&gt;#define PORT_READ32(address) (*(volatile uint32_t *)(address))&lt;/P&gt;&lt;P&gt;// Base addresses for the registers (these should be adjusted based on your MCU documentation)&lt;BR /&gt;#define MC_CGM_BASE 0x402D8000U // Base address of the Clock Generation Module (MC_CGM)&lt;BR /&gt;#define MC_ME_BASE 0x402DC000U // Base address of the Clock Management Module (MC_ME)&lt;BR /&gt;#define SIUL2_BASE 0x40290000U // Base address of the SIUL2 for GPIO&lt;/P&gt;&lt;P&gt;// Registers of the MC_CGM (Clock Generation Module)&lt;BR /&gt;#define MC_CGM_MUX_6_CSC (MC_CGM_BASE + 0x480U)&lt;BR /&gt;#define MC_CGM_MUX_6_CSS (MC_CGM_BASE + 0x484U)&lt;BR /&gt;#define MC_CGM_MUX_6_DC_0 (MC_CGM_BASE + 0x488U)&lt;/P&gt;&lt;P&gt;// Registers of the MC_ME (Clock Management Module)&lt;BR /&gt;#define MC_ME_PRTN0_COFB1_CLKEN (MC_ME_BASE + 0x134U) //0x402DC134&lt;BR /&gt;#define MC_ME_PRTN0_PUPD (MC_ME_BASE + 0x104U) //0x402DC104&lt;BR /&gt;#define MC_ME_CTL_KEY (MC_ME_BASE + 0x000U) //0x402DC000&lt;BR /&gt;#define MC_ME_PRTN0_STAT (MC_ME_BASE + 0x108U) //0x402DC108&lt;BR /&gt;#define MC_ME_GS (MC_ME_BASE + 0x008U) //0x402DC008&lt;BR /&gt;#define MC_ME_PRTN0_PCONF (MC_ME_BASE + 0x100U) //0x402DC100&lt;BR /&gt;#define MC_ME_PRTN0_COFB1_STAT (MC_ME_BASE + 0x114U) //0x402DC114&lt;/P&gt;&lt;P&gt;#define MC_ME_KEY 0x5AF0U&lt;BR /&gt;#define MC_ME_INVKEY 0xA50FU&lt;/P&gt;&lt;P&gt;// Registers of the SIUL2 (GPIO Control)&lt;BR /&gt;#define SIUL2_MSCR231 0x402905DC&lt;BR /&gt;#define SIUL2_GPDO231 0x402913E4&lt;/P&gt;&lt;P&gt;#define asm __asm__&lt;/P&gt;&lt;P&gt;// Initialize the clock using direct register access&lt;BR /&gt;void CLOCK_InitFIRC(void)&lt;BR /&gt;{&lt;BR /&gt;// Enable FIRC&lt;BR /&gt;uint32_t temp;&lt;BR /&gt;temp = PORT_READ32(MC_ME_PRTN0_COFB1_STAT); // Read current status&lt;BR /&gt;if ((temp &amp;amp; (1 &amp;lt;&amp;lt; 5)) == 0) {&lt;BR /&gt;PORT_WRITE32(MC_ME_PRTN0_COFB1_CLKEN, (1 &amp;lt;&amp;lt; 1)); // Enable FIRC&lt;BR /&gt;PORT_WRITE32(MC_ME_PRTN0_PCONF, (1 &amp;lt;&amp;lt; 0)); // Enable FIRC&lt;BR /&gt;PORT_WRITE32(MC_ME_PRTN0_PUPD, (1 &amp;lt;&amp;lt; 1)); // Enable update&lt;BR /&gt;PORT_WRITE32(MC_ME_CTL_KEY, MC_ME_KEY); // Unlock control register&lt;BR /&gt;PORT_WRITE32(MC_ME_CTL_KEY, ~MC_ME_KEY); // Lock control register&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Wait for FIRC stabilization&lt;BR /&gt;do {&lt;BR /&gt;temp = PORT_READ32(MC_CGM_MUX_6_CSS); // Read the current clock source selection&lt;BR /&gt;} while ((temp &amp;amp; 0x0F) != 0x0); // Check if FIRC is selected (FIRC should have 0x0)&lt;/P&gt;&lt;P&gt;// Configure MUX6 to use FIRC as the clock source&lt;BR /&gt;PORT_WRITE32(MC_CGM_MUX_6_CSC, 0x0); // Select FIRC as clock source for MUX6&lt;BR /&gt;PORT_WRITE32(MC_CGM_MUX_6_DC_0, 0x0); // Set divisor to 1 (no division)&lt;/P&gt;&lt;P&gt;// Check the status of the clock&lt;BR /&gt;uint32_t status_clk = PORT_READ32(MC_CGM_MUX_6_CSS); // Read current clock status&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt;// Initialize the clock&lt;BR /&gt;CLOCK_InitFIRC();&lt;/P&gt;&lt;P&gt;// Initialize the GPIO for the LED&lt;BR /&gt;PORT_WRITE32(SIUL2_MSCR231, 0x200000);&lt;/P&gt;&lt;P&gt;while(1)&lt;BR /&gt;{&lt;BR /&gt;PORT_WRITE8(SIUL2_GPDO231, 0x1);&lt;BR /&gt;for(uint32_t i = 0; i &amp;lt; 20e6; i++)&lt;BR /&gt;{&lt;BR /&gt;asm("nop");&lt;BR /&gt;}&lt;BR /&gt;PORT_WRITE8(SIUL2_GPDO231, 0x0);&lt;BR /&gt;for(uint32_t i = 0; i &amp;lt; 20e6; i++)&lt;BR /&gt;{&lt;BR /&gt;asm("nop");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Any help or suggestions would be greatly appreciated.&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 27 Feb 2026 14:12:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Enabling-FIRC-Clock-on-S32K396-in-Low-Level-Programming/m-p/2324432#M57033</guid>
      <dc:creator>Jesusear18</dc:creator>
      <dc:date>2026-02-27T14:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: Enabling FIRC Clock on S32K396 in Low-Level Programming</title>
      <link>https://community.nxp.com/t5/S32K/Enabling-FIRC-Clock-on-S32K396-in-Low-Level-Programming/m-p/2324480#M57036</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/258634"&gt;@Jesusear18&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note that FIRC is the default boot clock on S32K3 devices. It is always enabled in RUN mode, so there is no need to explicitly enable it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, the S32K39/S32K37/S32K36 Reference Manuals state that only SIRC_CLK and FIRC_CLK are enabled out of reset, and they remain enabled after any functional reset. All other clock sources start disabled and must be configured before use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR, VaneB&lt;/P&gt;</description>
      <pubDate>Fri, 27 Feb 2026 17:54:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Enabling-FIRC-Clock-on-S32K396-in-Low-Level-Programming/m-p/2324480#M57036</guid>
      <dc:creator>VaneB</dc:creator>
      <dc:date>2026-02-27T17:54:58Z</dc:date>
    </item>
  </channel>
</rss>

