Skip to content

Commit 8cec073

Browse files
committed
Fix the value of SystemCoreClock
The OS timer of RZ/A1 uses P0 clock, so until now it has been set the value of P0 clock in SystemCoreClock. Changed the system clock value to set to SystemCoreClock. Changed to refer to P0 clock macro instead of SystemCoreClock in OS timer processing.
1 parent b29b55a commit 8cec073

File tree

9 files changed

+37
-15
lines changed

9 files changed

+37
-15
lines changed

targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_GR_LYCHEE/device/os_tick_ostm.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <MBRZA1LU.h>
3131

3232
#include <cmsis.h>
33+
#include "mbed_drv_cfg.h"
3334

3435

3536
// Define OS TImer interrupt priority
@@ -62,15 +63,15 @@ int32_t OS_Tick_Setup (uint32_t freq, IRQHandler_t handler)
6263
// Get CPG.FRQCR[IFC] bits
6364
clock = (CPG.FRQCR >> 8) & 0x03;
6465

65-
// Determine Divider 2 output clock by using SystemCoreClock
66+
// Determine Divider 2 output clock by using RENESAS_RZ_A1_P0_CLK
6667
if (clock == 0x03U) {
67-
clock = (SystemCoreClock * 3U);
68+
clock = (RENESAS_RZ_A1_P0_CLK * 3U);
6869
}
6970
else if (clock == 0x01U) {
70-
clock = (SystemCoreClock * 3U)/2U;
71+
clock = (RENESAS_RZ_A1_P0_CLK * 3U)/2U;
7172
}
7273
else {
73-
clock = SystemCoreClock;
74+
clock = RENESAS_RZ_A1_P0_CLK;
7475
}
7576

7677
// Determine tick frequency

targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_GR_LYCHEE/device/system_RZ_A1LU.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include <RZ_A1LU.h>
3030
#include "RZ_A1_Init.h"
3131
#include "irq_ctrl.h"
32+
#include "mbed_drv_cfg.h"
33+
3234

3335
#define CS2_SDRAM_MODE_16BIT_CAS2_BR_BW (*(volatile uint16_t*)0x3FFFD040)
3436
#define CS3_SDRAM_MODE_16BIT_CAS2_BR_BW (*(volatile uint16_t*)0x3FFFE040)
@@ -45,7 +47,7 @@
4547
/*----------------------------------------------------------------------------
4648
System Core Clock Variable
4749
*----------------------------------------------------------------------------*/
48-
uint32_t SystemCoreClock = CM1_RENESAS_RZ_A1_P0_CLK;
50+
uint32_t SystemCoreClock = RENESAS_RZ_A1_SYS_CLK;
4951

5052
/*----------------------------------------------------------------------------
5153
System Core Clock update function

targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_GR_LYCHEE/mbed_drv_cfg.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434

3535
#define RENESAS_RZ_A1_P0_CLK CM1_RENESAS_RZ_A1_P0_CLK
3636

37+
/* Clock Mode 1 */
38+
/* CLKIN is 48MHz */
39+
/* Divider 1 uses 1/4 ratio, PLL x32 is ON */
40+
#define RENESAS_RZ_A1_SYS_CLK ((CM1_RENESAS_RZ_A1_CLKIN * 32U) / 4U)
41+
3742
#define LP_TICKER_MTU2_CH 2
3843

3944
/* flash (W25Q64JV) */

targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_RZ_A1H/device/os_tick_ostm.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <MBRZA1H.h>
3131

3232
#include <cmsis.h>
33+
#include "mbed_drv_cfg.h"
3334

3435

3536
// Define OS TImer interrupt priority
@@ -62,15 +63,15 @@ int32_t OS_Tick_Setup (uint32_t freq, IRQHandler_t handler)
6263
// Get CPG.FRQCR[IFC] bits
6364
clock = (CPG.FRQCR >> 8) & 0x03;
6465

65-
// Determine Divider 2 output clock by using SystemCoreClock
66+
// Determine Divider 2 output clock by using RENESAS_RZ_A1_P0_CLK
6667
if (clock == 0x03U) {
67-
clock = (SystemCoreClock * 3U);
68+
clock = (RENESAS_RZ_A1_P0_CLK * 3U);
6869
}
6970
else if (clock == 0x01U) {
70-
clock = (SystemCoreClock * 3U)/2U;
71+
clock = (RENESAS_RZ_A1_P0_CLK * 3U)/2U;
7172
}
7273
else {
73-
clock = SystemCoreClock;
74+
clock = RENESAS_RZ_A1_P0_CLK;
7475
}
7576

7677
// Determine tick frequency

targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_RZ_A1H/device/system_RZ_A1H.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <RZ_A1H.h>
3030
#include "RZ_A1_Init.h"
3131
#include "irq_ctrl.h"
32+
#include "mbed_drv_cfg.h"
3233

3334
#define CS2_SDRAM_MODE_16BIT_CAS2_BR_BW (*(volatile uint16_t*)0x3FFFD040)
3435
#define CS3_SDRAM_MODE_16BIT_CAS2_BR_BW (*(volatile uint16_t*)0x3FFFE040)
@@ -45,7 +46,7 @@
4546
/*----------------------------------------------------------------------------
4647
System Core Clock Variable
4748
*----------------------------------------------------------------------------*/
48-
uint32_t SystemCoreClock = CM0_RENESAS_RZ_A1_P0_CLK;
49+
uint32_t SystemCoreClock = RENESAS_RZ_A1_SYS_CLK;
4950

5051
/*----------------------------------------------------------------------------
5152
System Core Clock update function

targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_RZ_A1H/mbed_drv_cfg.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434

3535
#define RENESAS_RZ_A1_P0_CLK CM0_RENESAS_RZ_A1_P0_CLK
3636

37+
/* Clock Mode 0 */
38+
/* CLKIN is between 10MHz and 13.33MHz */
39+
/* Divider 1 uses 1/1 ratio, PLL x30 is ON */
40+
#define RENESAS_RZ_A1_SYS_CLK (CM0_RENESAS_RZ_A1_CLKIN * 30U)
41+
3742
#define LP_TICKER_MTU2_CH 3
3843

3944
/* flash (MX25L6433FM2I) */

targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_VK_RZ_A1H/device/os_tick_ostm.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <VKRZA1H.h>
3131

3232
#include <cmsis.h>
33+
#include "mbed_drv_cfg.h"
3334

3435

3536
// Define OS TImer interrupt priority
@@ -62,15 +63,15 @@ int32_t OS_Tick_Setup (uint32_t freq, IRQHandler_t handler)
6263
// Get CPG.FRQCR[IFC] bits
6364
clock = (CPG.FRQCR >> 8) & 0x03;
6465

65-
// Determine Divider 2 output clock by using SystemCoreClock
66+
// Determine Divider 2 output clock by using RENESAS_RZ_A1_P0_CLK
6667
if (clock == 0x03U) {
67-
clock = (SystemCoreClock * 3U);
68+
clock = (RENESAS_RZ_A1_P0_CLK * 3U);
6869
}
6970
else if (clock == 0x01U) {
70-
clock = (SystemCoreClock * 3U)/2U;
71+
clock = (RENESAS_RZ_A1_P0_CLK * 3U)/2U;
7172
}
7273
else {
73-
clock = SystemCoreClock;
74+
clock = RENESAS_RZ_A1_P0_CLK;
7475
}
7576

7677
// Determine tick frequency

targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_VK_RZ_A1H/device/system_VK_RZ_A1H.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <VK_RZ_A1H.h>
3030
#include "RZ_A1_Init.h"
3131
#include "irq_ctrl.h"
32+
#include "mbed_drv_cfg.h"
3233

3334
#define CS2_SDRAM_MODE_16BIT_CAS2_BR_BW (*(volatile uint16_t*)0x3FFFD040)
3435
#define CS3_SDRAM_MODE_16BIT_CAS2_BR_BW (*(volatile uint16_t*)0x3FFFE040)
@@ -45,7 +46,7 @@
4546
/*----------------------------------------------------------------------------
4647
System Core Clock Variable
4748
*----------------------------------------------------------------------------*/
48-
uint32_t SystemCoreClock = CM0_RENESAS_RZ_A1_P0_CLK;
49+
uint32_t SystemCoreClock = RENESAS_RZ_A1_SYS_CLK;
4950

5051
/*----------------------------------------------------------------------------
5152
System Core Clock update function

targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_VK_RZ_A1H/mbed_drv_cfg.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@
3434

3535
#define RENESAS_RZ_A1_P0_CLK CM0_RENESAS_RZ_A1_P0_CLK
3636

37+
/* Clock Mode 0 */
38+
/* CLKIN is between 10MHz and 13.33MHz */
39+
/* Divider 1 uses 1/1 ratio, PLL x30 is ON */
40+
#define RENESAS_RZ_A1_SYS_CLK (CM0_RENESAS_RZ_A1_CLKIN * 30U)
41+
3742
#endif

0 commit comments

Comments
 (0)