<?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>Kinetis MicrocontrollersのトピックRe: Flash clock configuration</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-clock-configuration/m-p/773225#M47014</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;At the end I cannot figure out why, the call:&amp;nbsp;callFlashRunCommand((FTFx_REG8_ACCESS_TYPE)(&amp;amp;FTFx-&amp;gt;FSTAT)); causes the reset of the mcu almost always when I try to debug it. Sometimes no. This is really hard to understand to me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 11 Dec 2017 10:36:41 GMT</pubDate>
    <dc:creator>giovannigherard</dc:creator>
    <dc:date>2017-12-11T10:36:41Z</dc:date>
    <item>
      <title>Flash clock configuration</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-clock-configuration/m-p/773222#M47011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All, I'm experiencing a strange problem that is for sure due to a wrong clock configuration but I'm struggling to solve it. Basically I have a board with a KE16F256 and a 24MHz Crystal. Everything was fine untill I started working with the flash (I'm writing a bootloader). So I decided to follow the provided sample fro program flash access.&lt;/P&gt;&lt;P&gt;The problem is that if I try to run the FLASH_Init function before configuring the clock the flash init function returns&amp;nbsp;kStatus_FLASH_Success but if I call the&amp;nbsp; FLASH_Init after (as it is supposed to be) the BOARD_InitBootClocks function generated by the MCUXpresso clock configuration tool the flash cannot be initializated correctly. I attached the screenshot oh the clock configuration. The following is my clock_config.c file:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt; * How to setup clock using clock driver functions:&lt;BR /&gt; *&lt;BR /&gt; * 1. Call CLOCK_InitXXX() to configure corresponding SCG clock source.&lt;BR /&gt; * Note: The clock could not be set when it is being used as system clock.&lt;BR /&gt; * In default out of reset, the CPU is clocked from FIRC(IRC48M),&lt;BR /&gt; * so before setting FIRC, change to use another avaliable clock source.&lt;BR /&gt; *&lt;BR /&gt; * 2. Call CLOCK_SetXtal0Freq() to set XTAL0 frequency based on board settings.&lt;BR /&gt; *&lt;BR /&gt; * 3. Call CLOCK_SetXxxModeSysClkConfig() to set SCG mode for Xxx run mode.&lt;BR /&gt; * Wait until the system clock source is changed to target source.&lt;BR /&gt; *&lt;BR /&gt; * 4. If power mode change is needed, call SMC_SetPowerModeProtection() to allow&lt;BR /&gt; * corresponding power mode and SMC_SetPowerModeXxx() to change to Xxx mode.&lt;BR /&gt; * Supported run mode and clock restrictions could be found in Reference Manual.&lt;BR /&gt; */&lt;/P&gt;&lt;P&gt;/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************&lt;BR /&gt;!!GlobalInfo&lt;BR /&gt;product: Clocks v3.0&lt;BR /&gt;processor: MKE16F256xxx16&lt;BR /&gt;package_id: MKE16F256VLH16&lt;BR /&gt;mcu_data: ksdk2_0&lt;BR /&gt;processor_version: 2.0.0&lt;BR /&gt; * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/&lt;/P&gt;&lt;P&gt;#include "fsl_smc.h"&lt;BR /&gt;#include "clock_config.h"&lt;/P&gt;&lt;P&gt;/*******************************************************************************&lt;BR /&gt; * Definitions&lt;BR /&gt; ******************************************************************************/&lt;BR /&gt;#define SIM_CHIPCTL_CAN_FLT_CLKSEL_SIRC 1U /*!&amp;lt; CAN filter clock select: SIRC clock */&lt;/P&gt;&lt;P&gt;/*******************************************************************************&lt;BR /&gt; * Variables&lt;BR /&gt; ******************************************************************************/&lt;BR /&gt;/* System clock frequency. */&lt;BR /&gt;extern uint32_t SystemCoreClock;&lt;/P&gt;&lt;P&gt;/*******************************************************************************&lt;BR /&gt; * Code&lt;BR /&gt; ******************************************************************************/&lt;BR /&gt;/*FUNCTION**********************************************************************&lt;BR /&gt; *&lt;BR /&gt; * Function Name : CLOCK_CONFIG_SetCanFltClock&lt;BR /&gt; * Description : Set the FlexCAN filter clock.&lt;BR /&gt; * Param src : The selected clock source.&lt;BR /&gt; *&lt;BR /&gt; *END**************************************************************************/&lt;BR /&gt;static void CLOCK_CONFIG_SetCanFltClock(uint8_t src)&lt;BR /&gt;{&lt;BR /&gt; SIM-&amp;gt;CHIPCTL = ((SIM-&amp;gt;CHIPCTL &amp;amp; ~SIM_CHIPCTL_CAN_FLT_CLK_SEL_MASK) | SIM_CHIPCTL_CAN_FLT_CLK_SEL(src));&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*FUNCTION**********************************************************************&lt;BR /&gt; *&lt;BR /&gt; * Function Name : CLOCK_CONFIG_FircSafeConfig&lt;BR /&gt; * Description : This function is used to safely configure FIRC clock.&lt;BR /&gt; * In default out of reset, the CPU is clocked from FIRC(IRC48M).&lt;BR /&gt; * Before setting FIRC, change to use SIRC as system clock,&lt;BR /&gt; * then configure FIRC. After FIRC is set, change back to use FIRC&lt;BR /&gt; * in case SIRC need to be configured.&lt;BR /&gt; * Param fircConfig : FIRC configuration.&lt;BR /&gt; *&lt;BR /&gt; *END**************************************************************************/&lt;BR /&gt;static void CLOCK_CONFIG_FircSafeConfig(const scg_firc_config_t *fircConfig)&lt;BR /&gt;{&lt;BR /&gt; scg_sys_clk_config_t curConfig;&lt;BR /&gt; const scg_sirc_config_t scgSircConfig = {.enableMode = kSCG_SircEnable,&lt;BR /&gt; .div1 = kSCG_AsyncClkDisable,&lt;BR /&gt; .div2 = kSCG_AsyncClkDivBy2,&lt;BR /&gt; .range = kSCG_SircRangeHigh};&lt;BR /&gt; scg_sys_clk_config_t sysClkSafeConfigSource = {&lt;BR /&gt; .divSlow = kSCG_SysClkDivBy4, /* Slow clock divider */&lt;BR /&gt; .divBus = kSCG_SysClkDivBy1, /* Bus clock divider */&lt;BR /&gt; .divCore = kSCG_SysClkDivBy1, /* Core clock divider */&lt;BR /&gt; .src = kSCG_SysClkSrcSirc /* System clock source */&lt;BR /&gt; };&lt;BR /&gt; /* Init Sirc. */&lt;BR /&gt; CLOCK_InitSirc(&amp;amp;scgSircConfig);&lt;BR /&gt; /* Change to use SIRC as system clock source to prepare to change FIRCCFG register. */&lt;BR /&gt; CLOCK_SetRunModeSysClkConfig(&amp;amp;sysClkSafeConfigSource);&lt;BR /&gt; /* Wait for clock source switch finished. */&lt;BR /&gt; do&lt;BR /&gt; {&lt;BR /&gt; CLOCK_GetCurSysClkConfig(&amp;amp;curConfig);&lt;BR /&gt; } while (curConfig.src != sysClkSafeConfigSource.src);&lt;/P&gt;&lt;P&gt;/* Init Firc. */&lt;BR /&gt; CLOCK_InitFirc(fircConfig);&lt;BR /&gt; /* Change back to use FIRC as system clock source in order to configure SIRC if needed. */&lt;BR /&gt; sysClkSafeConfigSource.src = kSCG_SysClkSrcFirc;&lt;BR /&gt; CLOCK_SetRunModeSysClkConfig(&amp;amp;sysClkSafeConfigSource);&lt;BR /&gt; /* Wait for clock source switch finished. */&lt;BR /&gt; do&lt;BR /&gt; {&lt;BR /&gt; CLOCK_GetCurSysClkConfig(&amp;amp;curConfig);&lt;BR /&gt; } while (curConfig.src != sysClkSafeConfigSource.src);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*******************************************************************************&lt;BR /&gt; ************************ BOARD_InitBootClocks function ************************&lt;BR /&gt; ******************************************************************************/&lt;BR /&gt;void BOARD_InitBootClocks(void)&lt;BR /&gt;{&lt;BR /&gt; ClocksConfig();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*******************************************************************************&lt;BR /&gt; ************************* Configuration ClocksConfig **************************&lt;BR /&gt; ******************************************************************************/&lt;BR /&gt;/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************&lt;BR /&gt;!!Configuration&lt;BR /&gt;name: ClocksConfig&lt;BR /&gt;called_from_default_init: true&lt;BR /&gt;outputs:&lt;BR /&gt;- {id: Bus_clock.outFreq, value: 75 MHz}&lt;BR /&gt;- {id: CANFLTCLKIN.outFreq, value: 8 MHz, locked: true, accuracy: '0.001'}&lt;BR /&gt;- {id: Core_clock.outFreq, value: 150 MHz}&lt;BR /&gt;- {id: Flash_clock.outFreq, value: 18.75 MHz}&lt;BR /&gt;- {id: LPO1KCLK.outFreq, value: 1 kHz}&lt;BR /&gt;- {id: LPO_clock.outFreq, value: 128 kHz}&lt;BR /&gt;- {id: PCC.PCC_ADC0_CLK.outFreq, value: 150 MHz}&lt;BR /&gt;- {id: PCC.PCC_FTM0_CLK.outFreq, value: 150 MHz}&lt;BR /&gt;- {id: PCC.PCC_FTM1_CLK.outFreq, value: 150 MHz}&lt;BR /&gt;- {id: PCC.PCC_FTM2_CLK.outFreq, value: 150 MHz}&lt;BR /&gt;- {id: PCC.PCC_LPSPI0_CLK.outFreq, value: 150 MHz}&lt;BR /&gt;- {id: PCC.PCC_LPSPI1_CLK.outFreq, value: 150 MHz}&lt;BR /&gt;- {id: PCC.PCC_LPUART0_CLK.outFreq, value: 24 MHz}&lt;BR /&gt;- {id: PCC.PCC_LPUART1_CLK.outFreq, value: 24 MHz}&lt;BR /&gt;- {id: PCC.PCC_LPUART2_CLK.outFreq, value: 24 MHz}&lt;BR /&gt;- {id: PLLDIV1_CLK.outFreq, value: 150 MHz}&lt;BR /&gt;- {id: PLLDIV2_CLK.outFreq, value: 150 MHz}&lt;BR /&gt;- {id: SIRC_CLK.outFreq, value: 8 MHz}&lt;BR /&gt;- {id: SOSCDIV1_CLK.outFreq, value: 24 MHz}&lt;BR /&gt;- {id: SOSCDIV2_CLK.outFreq, value: 24 MHz}&lt;BR /&gt;- {id: SOSC_CLK.outFreq, value: 24 MHz}&lt;BR /&gt;- {id: System_clock.outFreq, value: 150 MHz}&lt;BR /&gt;settings:&lt;BR /&gt;- {id: SCGMode, value: SPLL}&lt;BR /&gt;- {id: powerMode, value: HSRUN}&lt;BR /&gt;- {id: CANClkConfig, value: 'yes'}&lt;BR /&gt;- {id: PCC.PCC_ADC0_SEL.sel, value: SCG.PLLDIV2_CLK}&lt;BR /&gt;- {id: PCC.PCC_FTM0_SEL.sel, value: SCG.PLLDIV1_CLK}&lt;BR /&gt;- {id: PCC.PCC_FTM1_SEL.sel, value: SCG.PLLDIV1_CLK}&lt;BR /&gt;- {id: PCC.PCC_FTM2_SEL.sel, value: SCG.PLLDIV1_CLK}&lt;BR /&gt;- {id: PCC.PCC_LPSPI0_SEL.sel, value: SCG.PLLDIV2_CLK}&lt;BR /&gt;- {id: PCC.PCC_LPSPI1_SEL.sel, value: SCG.PLLDIV2_CLK}&lt;BR /&gt;- {id: PCC.PCC_LPUART0_SEL.sel, value: SCG.SOSCDIV2_CLK}&lt;BR /&gt;- {id: PCC.PCC_LPUART1_SEL.sel, value: SCG.SOSCDIV2_CLK}&lt;BR /&gt;- {id: PCC.PCC_LPUART2_SEL.sel, value: SCG.SOSCDIV2_CLK}&lt;BR /&gt;- {id: SCG.CLKOUTSEL.sel, value: SCG.SOSC}&lt;BR /&gt;- {id: SCG.DIVBUS.scale, value: '2', locked: true}&lt;BR /&gt;- {id: SCG.DIVCORE.scale, value: '1', locked: true}&lt;BR /&gt;- {id: SCG.DIVSLOW.scale, value: '8', locked: true}&lt;BR /&gt;- {id: SCG.FIRC_TRIMDIV.scale, value: '1', locked: true}&lt;BR /&gt;- {id: SCG.PREDIV.scale, value: '2', locked: true}&lt;BR /&gt;- {id: SCG.SCSSEL.sel, value: SCG.SPLL_DIV2_CLK}&lt;BR /&gt;- {id: SCG.SOSCDIV1.scale, value: '1', locked: true}&lt;BR /&gt;- {id: SCG.SOSCDIV2.scale, value: '1', locked: true}&lt;BR /&gt;- {id: SCG.SPLLDIV1.scale, value: '1'}&lt;BR /&gt;- {id: SCG.SPLLDIV2.scale, value: '1', locked: true}&lt;BR /&gt;- {id: SCG.SPLL_mul.scale, value: '25', locked: true}&lt;BR /&gt;- {id: 'SCG::RCCR[DIVBUS].bitField', value: Divide-by-2}&lt;BR /&gt;- {id: 'SCG::RCCR[DIVSLOW].bitField', value: Divide-by-8}&lt;BR /&gt;- {id: 'SCG::RCCR[SCS].bitField', value: System PLL (SPLL_CLK)}&lt;BR /&gt;- {id: SCG_SIRCCSR_SIRCSTEN_CFG, value: Enabled}&lt;BR /&gt;- {id: SCG_SOSCCFG_OSC_MODE_CFG, value: ModeOscLowPower}&lt;BR /&gt;- {id: SCG_SOSCCFG_RANGE_CFG, value: High}&lt;BR /&gt;- {id: SCG_SOSCCSR_SOSCEN_CFG, value: Enabled}&lt;BR /&gt;- {id: SCG_SOSCCSR_SOSCLPEN_CFG, value: Enabled}&lt;BR /&gt;- {id: SCG_SOSCCSR_SOSCSTEN_CFG, value: Enabled}&lt;BR /&gt;- {id: SCG_SPLLCSR_SPLLEN_CFG, value: Enabled}&lt;BR /&gt;- {id: SIM.CANFLTCLKSEL.sel, value: SCG.SIRC_CLK}&lt;BR /&gt;- {id: SIM.CLKOUTDIV.scale, value: '2', locked: true}&lt;BR /&gt;- {id: SIM.CLKOUTSEL.sel, value: PMC.LPO_CLK}&lt;BR /&gt;sources:&lt;BR /&gt;- {id: SCG.SOSC.outFreq, value: 24 MHz, enabled: true}&lt;BR /&gt; * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/&lt;/P&gt;&lt;P&gt;/*******************************************************************************&lt;BR /&gt; * Variables for ClocksConfig configuration&lt;BR /&gt; ******************************************************************************/&lt;BR /&gt;const scg_sys_clk_config_t g_sysClkConfig_ClocksConfig =&lt;BR /&gt; {&lt;BR /&gt; .divSlow = kSCG_SysClkDivBy8, /* Slow Clock Divider: divided by 8 */&lt;BR /&gt; .divBus = kSCG_SysClkDivBy2, /* Bus Clock Divider: divided by 2 */&lt;BR /&gt; .divCore = kSCG_SysClkDivBy1, /* Core Clock Divider: divided by 1 */&lt;BR /&gt; .src = kSCG_SysClkSrcSysPll, /* System PLL is selected as System Clock Source */&lt;BR /&gt; };&lt;BR /&gt;const scg_sosc_config_t g_scgSysOscConfig_ClocksConfig =&lt;BR /&gt; {&lt;BR /&gt; .freq = 24000000U, /* System Oscillator frequency: 24000000Hz */&lt;BR /&gt; .enableMode = kSCG_SysOscEnable | kSCG_SysOscEnableInStop | kSCG_SysOscEnableInLowPower,/* Enable System OSC clock, Enable System OSC in stop mode, Enable System OSC in low power mode */&lt;BR /&gt; .monitorMode = kSCG_SysOscMonitorDisable, /* Monitor disabled */&lt;BR /&gt; .div1 = kSCG_AsyncClkDivBy1, /* System OSC Clock Divider 1: divided by 1 */&lt;BR /&gt; .div2 = kSCG_AsyncClkDivBy1, /* System OSC Clock Divider 2: divided by 1 */&lt;BR /&gt; .workMode = kSCG_SysOscModeOscLowPower, /* Oscillator low power */&lt;BR /&gt; };&lt;BR /&gt;const scg_sirc_config_t g_scgSircConfig_ClocksConfig =&lt;BR /&gt; {&lt;BR /&gt; .enableMode = kSCG_SircEnable | kSCG_SircEnableInStop | kSCG_SircEnableInLowPower,/* Enable SIRC clock, Enable SIRC in stop mode, Enable SIRC in low power mode */&lt;BR /&gt; .div1 = kSCG_AsyncClkDisable, /* Slow IRC Clock Divider 1: Clock output is disabled */&lt;BR /&gt; .div2 = kSCG_AsyncClkDisable, /* Slow IRC Clock Divider 2: Clock output is disabled */&lt;BR /&gt; .range = kSCG_SircRangeHigh, /* Slow IRC high range clock (8 MHz) */&lt;BR /&gt; };&lt;BR /&gt;const scg_firc_config_t g_scgFircConfig_ClocksConfig =&lt;BR /&gt; {&lt;BR /&gt; .enableMode = kSCG_FircEnable, /* Enable FIRC clock */&lt;BR /&gt; .div1 = kSCG_AsyncClkDisable, /* Fast IRC Clock Divider 1: Clock output is disabled */&lt;BR /&gt; .div2 = kSCG_AsyncClkDisable, /* Fast IRC Clock Divider 2: Clock output is disabled */&lt;BR /&gt; .range = kSCG_FircRange48M, /* Fast IRC is trimmed to 48MHz */&lt;BR /&gt; .trimConfig = NULL, /* Fast IRC Trim disabled */&lt;BR /&gt; };&lt;BR /&gt;const scg_spll_config_t g_scgSysPllConfig_ClocksConfig =&lt;BR /&gt; {&lt;BR /&gt; .enableMode = kSCG_SysPllEnable, /* Enable SPLL clock */&lt;BR /&gt; .monitorMode = kSCG_SysPllMonitorDisable, /* Monitor disabled */&lt;BR /&gt; .div1 = kSCG_AsyncClkDivBy1, /* System PLL Clock Divider 1: divided by 1 */&lt;BR /&gt; .div2 = kSCG_AsyncClkDivBy1, /* System PLL Clock Divider 2: divided by 1 */&lt;BR /&gt; .src = kSCG_SysPllSrcSysOsc, /* System PLL clock source is System OSC */&lt;BR /&gt; .prediv = 1, /* Divided by 2 */&lt;BR /&gt; .mult = 9, /* Multiply Factor is 25 */&lt;BR /&gt; };&lt;BR /&gt;/*******************************************************************************&lt;BR /&gt; * Code for ClocksConfig configuration&lt;BR /&gt; ******************************************************************************/&lt;BR /&gt;void ClocksConfig(void)&lt;BR /&gt;{&lt;BR /&gt; scg_sys_clk_config_t curConfig;&lt;/P&gt;&lt;P&gt;/* Init SOSC according to board configuration. */&lt;BR /&gt; CLOCK_InitSysOsc(&amp;amp;g_scgSysOscConfig_ClocksConfig);&lt;BR /&gt; /* Set the XTAL0 frequency based on board settings. */&lt;BR /&gt; CLOCK_SetXtal0Freq(g_scgSysOscConfig_ClocksConfig.freq);&lt;BR /&gt; /* Init FIRC. */&lt;BR /&gt; CLOCK_CONFIG_FircSafeConfig(&amp;amp;g_scgFircConfig_ClocksConfig);&lt;BR /&gt; /* Set HSRUN power mode. */&lt;BR /&gt; SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll);&lt;BR /&gt; SMC_SetPowerModeHsrun(SMC);&lt;BR /&gt; while (SMC_GetPowerModeState(SMC) != kSMC_PowerStateHsrun)&lt;BR /&gt; {&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Init SIRC. */&lt;BR /&gt; CLOCK_InitSirc(&amp;amp;g_scgSircConfig_ClocksConfig);&lt;BR /&gt; /* Init SysPll. */&lt;BR /&gt; CLOCK_InitSysPll(&amp;amp;g_scgSysPllConfig_ClocksConfig);&lt;BR /&gt; /* Set SCG to SPLL mode. */&lt;BR /&gt; CLOCK_SetHsrunModeSysClkConfig(&amp;amp;g_sysClkConfig_ClocksConfig);&lt;BR /&gt; /* Wait for clock source switch finished. */&lt;BR /&gt; do&lt;BR /&gt; {&lt;BR /&gt; CLOCK_GetCurSysClkConfig(&amp;amp;curConfig);&lt;BR /&gt; } while (curConfig.src != g_sysClkConfig_ClocksConfig.src);&lt;BR /&gt; /* Set SystemCoreClock variable. */&lt;BR /&gt; SystemCoreClock = CLOCKSCONFIG_CORE_CLOCK;&lt;BR /&gt; /* Set CAN filter clock source. */&lt;BR /&gt; CLOCK_CONFIG_SetCanFltClock(SIM_CHIPCTL_CAN_FLT_CLKSEL_SIRC);&lt;BR /&gt; /* Set PCC ADC0 selection */&lt;BR /&gt; CLOCK_SetIpSrc(kCLOCK_Adc0, kCLOCK_IpSrcSysPllAsync);&lt;BR /&gt; /* Set PCC LPSPI0 selection */&lt;BR /&gt; CLOCK_SetIpSrc(kCLOCK_Lpspi0, kCLOCK_IpSrcSysPllAsync);&lt;BR /&gt; /* Set PCC LPSPI1 selection */&lt;BR /&gt; CLOCK_SetIpSrc(kCLOCK_Lpspi1, kCLOCK_IpSrcSysPllAsync);&lt;BR /&gt; /* Set PCC LPUART0 selection */&lt;BR /&gt; CLOCK_SetIpSrc(kCLOCK_Lpuart0, kCLOCK_IpSrcSysOscAsync);&lt;BR /&gt; /* Set PCC LPUART1 selection */&lt;BR /&gt; CLOCK_SetIpSrc(kCLOCK_Lpuart1, kCLOCK_IpSrcSysOscAsync);&lt;BR /&gt; /* Set PCC LPUART2 selection */&lt;BR /&gt; CLOCK_SetIpSrc(kCLOCK_Lpuart2, kCLOCK_IpSrcSysOscAsync);&lt;BR /&gt; /* Set PCC FTM0 selection */&lt;BR /&gt; CLOCK_SetIpSrc(kCLOCK_Ftm0, kCLOCK_IpSrcSysPllAsync);&lt;BR /&gt; /* Set PCC FTM1 selection */&lt;BR /&gt; CLOCK_SetIpSrc(kCLOCK_Ftm1, kCLOCK_IpSrcSysPllAsync);&lt;BR /&gt; /* Set PCC FTM2 selection */&lt;BR /&gt; CLOCK_SetIpSrc(kCLOCK_Ftm2, kCLOCK_IpSrcSysPllAsync);&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Dec 2017 15:50:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-clock-configuration/m-p/773222#M47011</guid>
      <dc:creator>giovannigherard</dc:creator>
      <dc:date>2017-12-07T15:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: Flash clock configuration</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-clock-configuration/m-p/773223#M47012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Giovanni,&lt;/P&gt;&lt;P&gt;This is because ""Attempts to write to the FlexRAM in HSRUN mode will be trapped with the ACCERR flag being set."&amp;nbsp; Please search "HSRUN" in the reference manual. You'll find many restriction descriptions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;jing&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Dec 2017 07:38:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-clock-configuration/m-p/773223#M47012</guid>
      <dc:creator>jingpan</dc:creator>
      <dc:date>2017-12-08T07:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: Flash clock configuration</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-clock-configuration/m-p/773224#M47013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, got. Now I have another problem. The FLASH_Init function I found in the example, after initializing the flash performs an erase to test the flash. When the flash erase reach the &lt;SPAN&gt;callFlashRunCommand((FTFx_REG8_ACCESS_TYPE)(&amp;amp;FTFx-&amp;gt;FSTAT)); function pointer inside&amp;nbsp;"&lt;SPAN&gt;flash_command_sequence(config);"&amp;nbsp;&lt;/SPAN&gt;the mcu resets itself. I report the body of the flash erase function and&amp;nbsp;flash_command_sequence&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;status_t FLASH_Erase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key)&lt;BR /&gt;{&lt;BR /&gt; uint32_t sectorSize;&lt;BR /&gt; flash_operation_config_t flashOperationInfo;&lt;BR /&gt; uint32_t endAddress; /* storing end address */&lt;BR /&gt; uint32_t numberOfSectors; /* number of sectors calculated by endAddress */&lt;BR /&gt; status_t returnCode;&lt;/P&gt;&lt;P&gt;flash_get_matched_operation_info(config, start, &amp;amp;flashOperationInfo);&lt;/P&gt;&lt;P&gt;/* Check the supplied address range. */&lt;BR /&gt; returnCode = flash_check_range(config, start, lengthInBytes, flashOperationInfo.sectorCmdAddressAligment);&lt;BR /&gt; if (returnCode)&lt;BR /&gt; {&lt;BR /&gt; return returnCode;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Validate the user key */&lt;BR /&gt; returnCode = flash_check_user_key(key);&lt;BR /&gt; if (returnCode)&lt;BR /&gt; {&lt;BR /&gt; return returnCode;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;start = flashOperationInfo.convertedAddress;&lt;BR /&gt; sectorSize = flashOperationInfo.activeSectorSize;&lt;/P&gt;&lt;P&gt;/* calculating Flash end address */&lt;BR /&gt; endAddress = start + lengthInBytes - 1;&lt;/P&gt;&lt;P&gt;/* re-calculate the endAddress and align it to the start of the next sector&lt;BR /&gt; * which will be used in the comparison below */&lt;BR /&gt; if (endAddress % sectorSize)&lt;BR /&gt; {&lt;BR /&gt; numberOfSectors = endAddress / sectorSize + 1;&lt;BR /&gt; endAddress = numberOfSectors * sectorSize - 1;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;flash_cache_clear_process(config, kFLASH_CacheClearProcessPre);&lt;/P&gt;&lt;P&gt;/* the start address will increment to the next sector address&lt;BR /&gt; * until it reaches the endAdddress */&lt;BR /&gt; while (start &amp;lt;= endAddress)&lt;BR /&gt; {&lt;BR /&gt; /* preparing passing parameter to erase a flash block */&lt;BR /&gt; kFCCOBx[0] = BYTES_JOIN_TO_WORD_1_3(FTFx_ERASE_SECTOR, start);&lt;/P&gt;&lt;P&gt;/* calling flash command sequence function to execute the command */&lt;BR /&gt; returnCode = flash_command_sequence(config);&lt;/P&gt;&lt;P&gt;/* calling flash callback function if it is available */&lt;BR /&gt; if (config-&amp;gt;PFlashCallback)&lt;BR /&gt; {&lt;BR /&gt; config-&amp;gt;PFlashCallback();&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* checking the success of command execution */&lt;BR /&gt; if (kStatus_FLASH_Success != returnCode)&lt;BR /&gt; {&lt;BR /&gt; break;&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; /* Increment to the next sector */&lt;BR /&gt; start += sectorSize;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;flash_cache_clear(config);&lt;/P&gt;&lt;P&gt;return (returnCode);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;static status_t flash_command_sequence(flash_config_t *config)&lt;BR /&gt;{&lt;BR /&gt; uint8_t registerValue;&lt;/P&gt;&lt;P&gt;#if FLASH_DRIVER_IS_FLASH_RESIDENT&lt;BR /&gt; /* clear RDCOLERR &amp;amp; ACCERR &amp;amp; FPVIOL flag in flash status register */&lt;BR /&gt; FTFx-&amp;gt;FSTAT = FTFx_FSTAT_RDCOLERR_MASK | FTFx_FSTAT_ACCERR_MASK | FTFx_FSTAT_FPVIOL_MASK;&lt;/P&gt;&lt;P&gt;status_t returnCode = flash_check_execute_in_ram_function_info(config);&lt;BR /&gt; if (kStatus_FLASH_Success != returnCode)&lt;BR /&gt; {&lt;BR /&gt; return returnCode;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* We pass the ftfx_fstat address as a parameter to flash_run_comamnd() instead of using&lt;BR /&gt; * pre-processed MICRO sentences or operating global variable in flash_run_comamnd()&lt;BR /&gt; * to make sure that flash_run_command() will be compiled into position-independent code (PIC). */&lt;BR /&gt; callFlashRunCommand((FTFx_REG8_ACCESS_TYPE)(&amp;amp;FTFx-&amp;gt;FSTAT));&lt;BR /&gt;#else&lt;BR /&gt; /* clear RDCOLERR &amp;amp; ACCERR &amp;amp; FPVIOL flag in flash status register */&lt;BR /&gt; FTFx-&amp;gt;FSTAT = FTFx_FSTAT_RDCOLERR_MASK | FTFx_FSTAT_ACCERR_MASK | FTFx_FSTAT_FPVIOL_MASK;&lt;/P&gt;&lt;P&gt;/* clear CCIF bit */&lt;BR /&gt; FTFx-&amp;gt;FSTAT = FTFx_FSTAT_CCIF_MASK;&lt;/P&gt;&lt;P&gt;/* Check CCIF bit of the flash status register, wait till it is set.&lt;BR /&gt; * IP team indicates that this loop will always complete. */&lt;BR /&gt; while (!(FTFx-&amp;gt;FSTAT &amp;amp; FTFx_FSTAT_CCIF_MASK))&lt;BR /&gt; {&lt;BR /&gt; }&lt;BR /&gt;#endif /* FLASH_DRIVER_IS_FLASH_RESIDENT */&lt;/P&gt;&lt;P&gt;/* Check error bits */&lt;BR /&gt; /* Get flash status register value */&lt;BR /&gt; registerValue = FTFx-&amp;gt;FSTAT;&lt;/P&gt;&lt;P&gt;/* checking access error */&lt;BR /&gt; if (registerValue &amp;amp; FTFx_FSTAT_ACCERR_MASK)&lt;BR /&gt; {&lt;BR /&gt; return kStatus_FLASH_AccessError;&lt;BR /&gt; }&lt;BR /&gt; /* checking protection error */&lt;BR /&gt; else if (registerValue &amp;amp; FTFx_FSTAT_FPVIOL_MASK)&lt;BR /&gt; {&lt;BR /&gt; return kStatus_FLASH_ProtectionViolation;&lt;BR /&gt; }&lt;BR /&gt; /* checking MGSTAT0 non-correctable error */&lt;BR /&gt; else if (registerValue &amp;amp; FTFx_FSTAT_MGSTAT0_MASK)&lt;BR /&gt; {&lt;BR /&gt; return kStatus_FLASH_CommandFailure;&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; return kStatus_FLASH_Success;&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Dec 2017 08:47:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-clock-configuration/m-p/773224#M47013</guid>
      <dc:creator>giovannigherard</dc:creator>
      <dc:date>2017-12-11T08:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: Flash clock configuration</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-clock-configuration/m-p/773225#M47014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;At the end I cannot figure out why, the call:&amp;nbsp;callFlashRunCommand((FTFx_REG8_ACCESS_TYPE)(&amp;amp;FTFx-&amp;gt;FSTAT)); causes the reset of the mcu almost always when I try to debug it. Sometimes no. This is really hard to understand to me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Dec 2017 10:36:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-clock-configuration/m-p/773225#M47014</guid>
      <dc:creator>giovannigherard</dc:creator>
      <dc:date>2017-12-11T10:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: Flash clock configuration</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-clock-configuration/m-p/773226#M47015</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I found the problem. I think interrupts must be disabled during flash erase.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Dec 2017 11:11:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-clock-configuration/m-p/773226#M47015</guid>
      <dc:creator>giovannigherard</dc:creator>
      <dc:date>2017-12-11T11:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: Flash clock configuration</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-clock-configuration/m-p/773227#M47016</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Giovanni, did disabling the interrupts during flash erase solve your issue?&amp;nbsp; When did you disable the interrupts?&amp;nbsp; Prior to call to FLASH_Erase?&amp;nbsp; Also, did you disable global?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Nov 2018 15:44:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-clock-configuration/m-p/773227#M47016</guid>
      <dc:creator>knovinger</dc:creator>
      <dc:date>2018-11-20T15:44:59Z</dc:date>
    </item>
  </channel>
</rss>

