<?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 Re: MCXA153 flash writing problem in Processor Expert Software</title>
    <link>https://community.nxp.com/t5/Processor-Expert-Software/MCXA153-flash-writing-problem/m-p/2196430#M6005</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/202847"&gt;@_Ferrari_&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your reply.&lt;/P&gt;
&lt;P&gt;Yes, you are right. You can&amp;nbsp; enable the cache after flash operation finished.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Alice&lt;/P&gt;</description>
    <pubDate>Fri, 31 Oct 2025 07:15:30 GMT</pubDate>
    <dc:creator>Alice_Yang</dc:creator>
    <dc:date>2025-10-31T07:15:30Z</dc:date>
    <item>
      <title>MCXA153 flash writing problem</title>
      <link>https://community.nxp.com/t5/Processor-Expert-Software/MCXA153-flash-writing-problem/m-p/2191272#M5997</link>
      <description>&lt;P&gt;Dear all,&lt;BR /&gt;I am developing an application based on the MCXA153 processor. The project uses an external 16MHz crystal, and I have modified the clock configuration, according to your suggestion, to obtain 96MHz as the Main clock.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="_Ferrari__0-1761204691515.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/362256i76A6855EAA8AA269/image-size/medium?v=v2&amp;amp;px=400" role="button" title="_Ferrari__0-1761204691515.png" alt="_Ferrari__0-1761204691515.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Also following your instructions, I used the information from the 'romapi_flashiap' project to be able to write to the flash.&lt;BR /&gt;Everything works fine, but after the first flash write operation, the Main clock completely changed.&lt;/P&gt;&lt;P&gt;In this post you can find the class and method that I used.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have you ever had a similar problem?&lt;BR /&gt;How was it solved?&lt;BR /&gt;Thank you very much for your cooperation and your help.&lt;BR /&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;class flash {
public:
	flash();
	virtual ~flash();
	void init();
	int32_t flashWrite(uint8_t *source, int32_t size);
	int32_t flashRead(uint8_t *pDest, int32_t size) ;
private:
    status_t status;
    uint32_t destAdrss; /* Address of the target location */
    uint32_t i, failedAddress, failedData;
    uint32_t pflashBlockBase  ;
    uint32_t pflashTotalSize  ;
    uint32_t pflashSectorSize ;
    uint32_t PflashPageSize   ;

    flash_config_t s_flashDriver;

    union _uBuffer buffer;

    void speculation_buffer_clear();
    void lpcac_clear();
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;void flash::init() {
	pflashBlockBase = 0U;
	pflashTotalSize = 0U;
	pflashSectorSize = 0U;
	PflashPageSize = 0U;

	FLASH_API-&amp;gt;flash_init(&amp;amp;s_flashDriver);

	/* Get flash properties kFLASH_ApiEraseKey */
	FLASH_API-&amp;gt;flash_get_property(&amp;amp;s_flashDriver, kFLASH_PropertyPflashBlockBaseAddr, &amp;amp;pflashBlockBase);
	FLASH_API-&amp;gt;flash_get_property(&amp;amp;s_flashDriver, kFLASH_PropertyPflashSectorSize, &amp;amp;pflashSectorSize);
	FLASH_API-&amp;gt;flash_get_property(&amp;amp;s_flashDriver, kFLASH_PropertyPflashTotalSize, &amp;amp;pflashTotalSize);
	FLASH_API-&amp;gt;flash_get_property(&amp;amp;s_flashDriver, kFLASH_PropertyPflashPageSize, &amp;amp;PflashPageSize);

	destAdrss = pflashBlockBase + (pflashTotalSize - (SECTOR_INDEX_FROM_END * pflashSectorSize));
}

int32_t flash::flashWrite(uint8_t *source, int32_t size) {

	status = FLASH_API-&amp;gt;flash_erase_sector(&amp;amp;s_flashDriver, destAdrss, pflashSectorSize, kFLASH_ApiEraseKey);
	if (status == kStatus_Success) {
		speculation_buffer_clear();
		lpcac_clear();
		status = FLASH_API-&amp;gt;flash_verify_erase_sector(&amp;amp;s_flashDriver, destAdrss, pflashSectorSize);
		if (status == kStatus_Success) {
			status = FLASH_API-&amp;gt;flash_program_page(&amp;amp;s_flashDriver, destAdrss, (uint8_t*) source, size);
		}
		speculation_buffer_clear();
		lpcac_clear();
	}
	return status;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Oct 2025 07:38:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Processor-Expert-Software/MCXA153-flash-writing-problem/m-p/2191272#M5997</guid>
      <dc:creator>_Ferrari_</dc:creator>
      <dc:date>2025-10-23T07:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: MCXA153 flash writing problem</title>
      <link>https://community.nxp.com/t5/Processor-Expert-Software/MCXA153-flash-writing-problem/m-p/2192223#M5998</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/202847"&gt;@_Ferrari_&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;but after the first flash write operation, the Main clock completely changed."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;-&amp;gt;&amp;gt;&amp;nbsp;&lt;/SPAN&gt;Do you mean that after running for a while, you noticed the main clock changed and is no longer 96 MHz?&lt;BR /&gt;And the main clock is 96 MHz when running &lt;CODE&gt;romapi_flashiap&lt;/CODE&gt;?&lt;BR /&gt;How did you observe this?&lt;BR /&gt;Could you please share a screenshot or log to show the behavior?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Fri, 24 Oct 2025 03:47:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Processor-Expert-Software/MCXA153-flash-writing-problem/m-p/2192223#M5998</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2025-10-24T03:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: MCXA153 flash writing problem</title>
      <link>https://community.nxp.com/t5/Processor-Expert-Software/MCXA153-flash-writing-problem/m-p/2193387#M6000</link>
      <description>&lt;P&gt;I analyzed the problem in detail and would like to present the result of my measurements.&lt;/P&gt;&lt;P&gt;I developed two programs. The first uses the CTIMER0 timer interrupt to toggle a CPU pin with a period of 20 microseconds (10 microseconds OFF and 10 microseconds ON).&lt;BR /&gt;The clock source for CTIMER0 is the Main CLOCK at 96MHz. As seen in the image, the period does not change both before and after the write operation. (see the&amp;nbsp; A1-A2 and B1-B2 cursors)&lt;BR /&gt;This means that the 96MHz clock doesn't change, but, as can be noted, interrupts are disabled for approximately 500 microseconds during the flash write phase. (see the C1-C2 cursors)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;// PROGRAM 1
uint8_t buffer[128]; 
volatile int32_t OnOff = 1;

int main(void) {

	/* Init board hardware. */

	BOARD_InitBootPins();
	BOARD_InitBootClocks();
	BOARD_InitBootPeripherals();
#ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL
	/* Init FSL debug console. */
	// BOARD_InitDebugConsole();
#endif
	memoryFlash.init();
	for(int i=0;i&amp;lt;128;i++) {
		buffer[i]=(uint8_t)i;
	}
	SDK_DelayAtLeastUs(100, SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY);
	memoryFlash.flashWrite(buffer,128);
	SDK_DelayAtLeastUs(100, SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY);
	while(1);
	return 0;
}

// INTERRUPT ROUTINE
void TestBit(uint32_t flg)
{
	GPIO_PinWrite(BOARD_INITPINS_RS485_TX_GPIO,	BOARD_INITPINS_RS485_TX_GPIO_PIN, OnOff);
	OnOff = !OnOff;
}&lt;/LI-CODE&gt;&lt;P&gt;Image 1&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="_Ferrari__0-1761556500148.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/362668i7B39D1D2ECABB59F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="_Ferrari__0-1761556500148.png" alt="_Ferrari__0-1761556500148.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The second program toggles the CPU pin 10 times using a dedicated routine (togglePin).&lt;BR /&gt;As seen in the image, before the write operation, the period is approximately 640 nanoseconds (320 OFF and 320 ON).&lt;/P&gt;&lt;P&gt;(see the A1-A2 cursor on the image 2)&lt;/P&gt;&lt;P&gt;After the flash write operation, the half-period lengthens by about three times (from 320 nanoseconds to 1.52 microseconds) (wait states are probably being added).&amp;nbsp;&amp;nbsp;(see the B1-B2 cursor on the image 3)&lt;BR /&gt;This obviously slows down the program execution.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;// PROGRAM 2

flash memoryFlash;
uint8_t buffer[128];
volatile int32_t OnOff = 1;


static void togglePin()
{
	for(int i=0;i&amp;lt;10;i++) {
		GPIO_PinWrite(BOARD_INITPINS_RS485_TX_GPIO,	BOARD_INITPINS_RS485_TX_GPIO_PIN, OnOff);
		OnOff = !OnOff;
	}
}

int main(void) {

	/* Init board hardware. */

	BOARD_InitBootPins();
	BOARD_InitBootClocks();
	BOARD_InitBootPeripherals();
#ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL
	/* Init FSL debug console. */
	// BOARD_InitDebugConsole();
#endif
	memoryFlash.init();
	for(int i=0;i&amp;lt;128;i++) {
		buffer[i]=(uint8_t)i;
	}
	togglePin();
	memoryFlash.flashWrite(buffer,128);
	togglePin();
	while(1);
	return 0;
}&lt;/LI-CODE&gt;&lt;P&gt;Image 2&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="_Ferrari__1-1761557055673.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/362673i0A4AD5C059BC3954/image-size/medium?v=v2&amp;amp;px=400" role="button" title="_Ferrari__1-1761557055673.png" alt="_Ferrari__1-1761557055673.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Image 3&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="_Ferrari__2-1761557100481.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/362675i30370536BDE5E344/image-size/medium?v=v2&amp;amp;px=400" role="button" title="_Ferrari__2-1761557100481.png" alt="_Ferrari__2-1761557100481.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Therefore:&lt;/P&gt;&lt;P&gt;1) How can I prevent interrupts from being disabled during the flash write operation?&lt;BR /&gt;2) How can I prevent the program from slowing down after the flash write operation?&lt;/P&gt;&lt;P&gt;Thank you very much for your help and cooperation&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2025 09:28:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Processor-Expert-Software/MCXA153-flash-writing-problem/m-p/2193387#M6000</guid>
      <dc:creator>_Ferrari_</dc:creator>
      <dc:date>2025-10-27T09:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: MCXA153 flash writing problem</title>
      <link>https://community.nxp.com/t5/Processor-Expert-Software/MCXA153-flash-writing-problem/m-p/2194268#M6001</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/202847"&gt;@_Ferrari_&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1) How can I prevent interrupts from being disabled during the flash write operation?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;-&amp;gt;&amp;gt;It is not recommended to keep interrupts enabled during flash write operations. Disabling interrupts helps prevent data corruption.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2) How can I prevent the program from slowing down after the flash write operation?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;-&amp;gt;&amp;gt;After the flash write is completed, the program should not run slowly—this is not related. Regarding the clock, you can measure it using the clock output pin.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;BR&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Alice&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2025 10:51:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Processor-Expert-Software/MCXA153-flash-writing-problem/m-p/2194268#M6001</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2025-10-28T10:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: MCXA153 flash writing problem</title>
      <link>https://community.nxp.com/t5/Processor-Expert-Software/MCXA153-flash-writing-problem/m-p/2195803#M6004</link>
      <description>&lt;P&gt;Thank you for your answer&lt;/P&gt;&lt;P&gt;You wrote:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-&amp;gt;&amp;gt;It is not recommended to keep interrupts enabled during flash write operations. Disabling interrupts helps prevent data corruption.&lt;/P&gt;&lt;P&gt;However, I seem to recall that this is only true if, during the execution of an interrupt service routine, I try to read data or execute code that resides in the flash block I am currently erasing or writing.&lt;/P&gt;&lt;P&gt;-&amp;gt;&amp;gt;After the flash write is completed, the program should not run slowly—this is not related. Regarding the clock, you can measure it using the clock output pin.&lt;/P&gt;&lt;P&gt;As you suggested, I followed the 'romapi_flashiap' example.&lt;BR /&gt;In the flash writing routine, you disable the microprocessor's cache memory but do not re-enable it at the end of the writing.&lt;BR /&gt;Therefore, after a flash write, the software's execution speed is lower.&lt;/P&gt;&lt;P&gt;(flashiap.c routine in romapi_flashiap example)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; PRINTF("\r\n Erase a sector of flash");
    status = FLASH_API-&amp;gt;flash_erase_sector(&amp;amp;s_flashDriver, destAdrss, pflashSectorSize, kFLASH_ApiEraseKey);
    if (status != kStatus_Success)
    {
        error_trap();
    }

    /* Clear speculation buffer and lpcac. */
    speculation_buffer_clear();
    lpcac_clear();
// ------------------------
// CACHE MEMORY IS DISABLED
// ------------------------
    /* Verify if the given flash range is successfully erased. */
    PRINTF("\r\n Calling flash_verify_erase_sector() API.");
    status = FLASH_API-&amp;gt;flash_verify_erase_sector(&amp;amp;s_flashDriver, destAdrss, pflashSectorSize);
    if (status == kStatus_Success)
    {
        PRINTF("\r\n Successfully erased sector: 0x%x -&amp;gt; 0x%x\r\n", destAdrss, (destAdrss + pflashSectorSize));
    }
    else
    {
        error_trap();
    }

    /* Prepare user buffer. */
    for (i = 0; i &amp;lt; BUFFER_LEN; i++)
    {
        s_buffer[i] = i;
    }

    /* Start programming specified flash region */
    PRINTF("\r\n Calling FLASH_Program() API.");
    status = FLASH_API-&amp;gt;flash_program_page(&amp;amp;s_flashDriver, destAdrss, (uint8_t *)s_buffer, sizeof(s_buffer));
    if (status != kStatus_Success)
    {
        error_trap();
    }

    /* Clear speculation buffer and lpcac. */
    speculation_buffer_clear();
    lpcac_clear();
// ------------------------
// CACHE MEMORY IS DISABLED
// ------------------------&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you suggested I&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Oct 2025 11:54:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Processor-Expert-Software/MCXA153-flash-writing-problem/m-p/2195803#M6004</guid>
      <dc:creator>_Ferrari_</dc:creator>
      <dc:date>2025-10-30T11:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: MCXA153 flash writing problem</title>
      <link>https://community.nxp.com/t5/Processor-Expert-Software/MCXA153-flash-writing-problem/m-p/2196430#M6005</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/202847"&gt;@_Ferrari_&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your reply.&lt;/P&gt;
&lt;P&gt;Yes, you are right. You can&amp;nbsp; enable the cache after flash operation finished.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Fri, 31 Oct 2025 07:15:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Processor-Expert-Software/MCXA153-flash-writing-problem/m-p/2196430#M6005</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2025-10-31T07:15:30Z</dc:date>
    </item>
  </channel>
</rss>

