Hi,
I'm changing the System clock to 96MHz and 12 MHz for operations. when i change the system clock, Code Flash erase, write functions are not working. Also, the flash functions return FLASH_SUCCESS even though the erase function is failed. I'm not sure if any other setting has to be done for changing system clock.
My main clock is 12MHz with external oscillator.
PLL Circuit Frequency division is x1.
PLL Circuit Frequency Multiplication is x16
I'm maintaining all clocks (FlashIF, ICLK, peripheral and external bus clock) to 12 MHz.
And based on operations, i want to change to high frequency (ICLK to 96MHz)so i'm using below code.
/* Protect off. */ SYSTEM.PRCR.WORD = 0xA50B; /* Select the clock based upon user's choice. */ // clock_source_select2(); delay_us(10); if(HIGH_FREQUENCY == ucClockSpeed){ SYSTEM.SCKCR.BIT.ICK = 1; // 192/2 =96MHz - Ext clk x N SYSTEM.ROMWT.BYTE = 0x01; } else { SYSTEM.SCKCR.BIT.ICK = 4; // 192/16 =12MHz - Ext clk x N SYSTEM.ROMWT.BYTE = 0x00; } delay_us(50); // /* Protect on. */ SYSTEM.PRCR.WORD = 0xA500;
Hi dear JSAN. The flash peripheral write function has some precautions and variables related to the clock.
1- In the (R01AN0544EJ0300 ) it's claimed the lowest frequency of the FLCK and PCLK as below
2-There's a register in the FLASH unit that is responsible for holding the FCLK clock and must be compatible with the running clock:
The Flash driver's API handles that configuration but you need to specify the new clock when using Flash driver as below:
Also, you might find this knowledge base useful: https://en-support.renesas.com/knowledgeBase/16980456
I hope you find this helpful. Don't hesitate to ask further questions if needed.
Best regards. Hossein
If this or any other user's response answers your concern, kindly verify the answer. Thank you!
Renesas Engineering Community Moderatorhttps://community.renesas.com/https://academy.renesas.com/en-support.renesas.com/.../
hi,
thanks for prompt response.
I am working on Rx671 controller. I have checked the registers mentioned but i couldn't find them in the hardware manual. Also the r_flash_config.h doesn't have any of the mentioned information.
When i set ICLK to 96MHz/12MHz, flash operations to code are not shown immediately in the memory browser and are taking time to show.
Sorry for the misunderstanding, the document I was referencing wasn't for the new RX671 Series, The reference document for RX671 is 'R01AN2184EJ0511' (Flash Module Using Firmware Integration Technology).
The place you need to seek that is here: (but make sure you've installed the latest FIT Drivers in e2studio)
As shown in the snippet above, the r_flash_control() function informs the flash driver of the working frequency as above.
The default is the value which is configured by the smart configurator. but you can simply invoke the r-flash_control(FLASH_CMD_CONFIG_CLOCK, &yourOperatingClock); each time you change the clock.
I hope it helps. keep me posted about the result.