Skip to content

Commit 5b36de9

Browse files
committed
nrf52840: add workaround for RTC errata 20
include thered main stack for cmsis rtos
1 parent f1c3d75 commit 5b36de9

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ __attribute__((used)) void _mutex_release (OS_ID *mutex) {
354354
/* Main Thread definition */
355355
extern void pre_main (void);
356356

357-
#if defined(TARGET_MCU_NRF52832) ||\
357+
#if defined(TARGET_MCU_NRF52840) ||\
358358
defined(TARGET_MCU_NRF51822) || defined(TARGET_MCU_NRF52832) || defined (TARGET_STM32F334R8) ||\
359359
defined(TARGET_STM32F070RB) || defined(TARGET_STM32F072RB) || \
360360
defined(TARGET_STM32F302R8) || defined(TARGET_STM32F303K8) || defined (TARGET_STM32F334C8) ||\

targets/TARGET_NORDIC/TARGET_NRF5_SDK13/us_ticker.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@ void COMMON_RTC_IRQ_HANDLER(void)
7676
}
7777
}
7878

79+
// Function for fix errata 20: RTC Register values are invalid
80+
__STATIC_INLINE void errata_20(void)
81+
{
82+
#if defined(NRF52_ERRATA_20)
83+
if (!softdevice_handler_is_enabled())
84+
{
85+
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
86+
NRF_CLOCK->TASKS_LFCLKSTART = 1;
87+
while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) {}
88+
}
89+
NRF_RTC1->TASKS_STOP = 0;
90+
#endif
91+
}
92+
7993
#if (defined (__ICCARM__)) && defined(TARGET_MCU_NRF51822)//IAR
8094
__stackless __task
8195
#endif
@@ -87,6 +101,8 @@ void common_rtc_init(void)
87101
return;
88102
}
89103

104+
errata_20();
105+
90106
NVIC_SetVector(RTC1_IRQn, (uint32_t)RTC1_IRQHandler);
91107

92108
// RTC is driven by the low frequency (32.768 kHz) clock, a proper request

targets/targets.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2560,7 +2560,7 @@
25602560
"MCU_NRF52840": {
25612561
"inherits": ["Target"],
25622562
"core": "Cortex-M4F",
2563-
"macros": ["TARGET_NRF52840", "BLE_STACK_SUPPORT_REQD", "SOFTDEVICE_PRESENT", "S140", "NRF_SD_BLE_API_VERSION=5", "NRF52840_XXAA", "NRF_DFU_SETTINGS_VERSION=1"],
2563+
"macros": ["TARGET_NRF52840", "BLE_STACK_SUPPORT_REQD", "SOFTDEVICE_PRESENT", "S140", "NRF_SD_BLE_API_VERSION=5", "NRF52840_XXAA", "NRF_DFU_SETTINGS_VERSION=1", "NRF_SD_BLE_API_VERSION=5"],
25642564
"extra_labels": ["NORDIC", "MCU_NRF52840", "NRF5_SDK13"],
25652565
"OUTPUT_EXT": "hex",
25662566
"is_disk_virtual": true,
@@ -2598,7 +2598,7 @@
25982598
"NRF52840_DK": {
25992599
"supported_form_factors": ["ARDUINO"],
26002600
"inherits": ["MCU_NRF52840"],
2601-
"macros_add": ["BOARD_PCA10056", "CONFIG_GPIO_AS_PINRESET", "SWI_DISABLE0"],
2601+
"macros_add": ["BOARD_PCA10056", "CONFIG_GPIO_AS_PINRESET", "SWI_DISABLE0", "NRF52_ERRATA_20"],
26022602
"device_has": ["ANALOGIN", "ERROR_PATTERN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"],
26032603
"release_versions": ["2", "5"],
26042604
"device_name": "nRF52840_xxAA"

0 commit comments

Comments
 (0)