Skip to content

Commit e870ba2

Browse files
bigdinotechsys_maker
authored and
sys_maker
committed
Ensure RTC clock scaling is set to 1Hz
-needed to make sure that the RTC scaling is consitent with the factory firmware and CODK-M based firmware
1 parent de208be commit e870ba2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

variants/arduino_101/variant.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,12 @@ void initVariant( void )
240240
variantGpioInit();
241241
variantPwmInit();
242242
variantAdcInit();
243-
243+
244+
//set RTC clock divider to 32768(1 Hz)
245+
*SYS_CLK_CTL |= RTC_DIV_1HZ_MASK;
246+
*SYS_CLK_CTL &= ~(1 << CCU_RTC_CLK_DIV_EN);
247+
*SYS_CLK_CTL |= 1 << CCU_RTC_CLK_DIV_EN;
248+
244249
cfw_platform_init();
245250

246251
// Add for debug corelib

variants/arduino_101/variant.h

+8
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ extern "C"{
146146
#define ADC_RESOLUTION 12
147147
#define ADC_CLOCK_GATE (1 << 31)
148148

149+
/*
150+
* Clocking
151+
*/
152+
153+
#define SYS_CLK_CTL (volatile int*)0xB0800038
154+
#define CCU_RTC_CLK_DIV_EN 2
155+
#define RTC_DIV_1HZ_MASK 0x00000078
156+
149157
#define digitalPinToBitMask(P) (1 << g_APinDescription[P].ulGPIOId)
150158

151159
//static uint8_t __unused_var_POR;

0 commit comments

Comments
 (0)