2 years, 6 months ago.

System clock

I Have a GR Peach that is running at 13MHz. but can run up to 400MHz. How can I change this in mbed, how can I see what mbed has set the main system core clock too.

Comment on this question

2 Answers

2 years, 6 months ago.

Hi Ian,

You view/make changes to the System Clock speed in the following files within your IDE or text editor:

File 1: /mbed-os/targets/TARGET_RENESAS/TARGET_RZ_A1H/device/system_MBRZA1H.c

Functions: SystemCoreClockUpdate

File 2: /mbed-os/targets/TARGET_RENESAS/TARGET_RZ_A1H/device/RZ_A1_Init.c

Functions: RZ_A1_InitClock

- Jenny

2 years, 6 months ago.

You can inspect the system core clock by printing it to your terminal:

pc.printf("SystemCoreClock is %d Hz\r\n", SystemCoreClock);  

Note that to change the system clock you can delete the mbed lib from your project, import the mbed source instead and modify the 'system_xxx.c'' files as shown above. This code is executed before all global variable instantiations and before your ''main'' starts. Alternatively, you can copy only the system clock setup sourcecode bits and call them again from your ''main'' code. In the latter case you will also have to re-initialise all previously declared objects that depend on the clock speed (e.g. serial ports, timers) or declare them after changing the clock speed.

Hi Jennifer, I have added the mbed source and re-compiled the my source and it's still not running fast. I have created a DigitalOut and I am setting it and then clearing it in a while loop. the toggle frequency is 980KHz or a period of 1us. the settings for the clock are correct void RZ_A1_InitClock(void) { /* Cancel L2C standby status before clock change */ L2CREG15_POWER_CTRL = 0x00000001;

/* Clock settings */ /* ClockMode0 */ CPG.FRQCR = 0x1035; /* CPU Clock =399.99MHz */ CPG.FRQCR2 = 0x0001; /* G Clock =266.66MHz */

return; }

I just think that the program is not implementing it, can you advise.

Regards Ian

posted by Ian De Dominicis 12 Jun 2017

You need to log in to post a question