void SystemInit(void) { // Prepare the peripherals for use as indicated by the PAN 26 "System: Manual setup is required // to enable the use of peripherals" found at Product Anomaly document for your device found at // https://www.nordicsemi.com/. The side effect of executing these instructions in the devices // that do not need it is that the new peripherals in the second generation devices (LPCOMP for // example) will not be available. if (is_manual_peripheral_setup_needed()){ *(uint32_t volatile *)0x40000504 = 0xC007FFDF; *(uint32_t volatile *)0x40006C18 = 0x00008000; } // Disable PROTENSET registers under debug, as indicated by PAN 59 "MPU: Reset value of DISABLEINDEBUG // register is incorrect" found at Product Anomaly document four your device found at // https://www.nordicsemi.com/. There is no side effect of using these instruction if not needed. if (is_disabled_in_debug_needed()){ NRF_MPU->DISABLEINDEBUG = MPU_DISABLEINDEBUG_DISABLEINDEBUG_Disabled << MPU_DISABLEINDEBUG_DISABLEINDEBUG_Pos; } // Start 16 MHz crystal oscillator. NRF_CLOCK->EVENTS_HFCLKSTARTED = 0; NRF_CLOCK->TASKS_HFCLKSTART = 1; // Wait for the external oscillator to start up. while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) { // Do nothing. } }
void SystemInit(void) { NRF_CLOCK->XTALFREQ = CLOCK_XTALFREQ_XTALFREQ_16MHz; /* nRF51 has default RAM off when Softdevice not present, we need to turn on RAM before calling any functions * We turn all RAM on here. */ NRF_POWER->RAMON = 0xf000f; /* If desired, switch off the unused RAM to lower consumption by the use of RAMON register. It can also be done in the application main() function. */ /* Prepare the peripherals for use as indicated by the PAN 26 "System: Manual setup is required to enable the use of peripherals" found at Product Anomaly document for your device found at https://www.nordicsemi.com/. The side effect of executing these instructions in the devices that do not need it is that the new peripherals in the second generation devices (LPCOMP for example) will not be available. */ if (is_manual_peripheral_setup_needed()) { *(uint32_t volatile *)0x40000504 = 0xC007FFDF; *(uint32_t volatile *)0x40006C18 = 0x00008000; } /* Disable PROTENSET registers under debug, as indicated by PAN 59 "MPU: Reset value of DISABLEINDEBUG register is incorrect" found at Product Anomaly document four your device found at https://www.nordicsemi.com/. There is no side effect of using these instruction if not needed. */ if (is_disabled_in_debug_needed()) { NRF_MPU->DISABLEINDEBUG = MPU_DISABLEINDEBUG_DISABLEINDEBUG_Disabled << MPU_DISABLEINDEBUG_DISABLEINDEBUG_Pos; } }
void SystemInit(void) { /* If desired, switch off the unused RAM to lower consumption by the use of RAMON register. It can also be done in the application main() function. */ /* Prepare the peripherals for use as indicated by the PAN 26 "System: Manual setup is required to enable the use of peripherals" found at Product Anomaly document for your device found at https://www.nordicsemi.com/. The side effect of executing these instructions in the devices that do not need it is that the new peripherals in the second generation devices (LPCOMP for example) will not be available. */ if (is_manual_peripheral_setup_needed()) { *(uint32_t volatile *)0x40000504 = 0xC007FFDF; *(uint32_t volatile *)0x40006C18 = 0x00008000; } /* Disable PROTENSET registers under debug, as indicated by PAN 59 "MPU: Reset value of DISABLEINDEBUG register is incorrect" found at Product Anomaly document four your device found at https://www.nordicsemi.com/. There is no side effect of using these instruction if not needed. */ if (is_disabled_in_debug_needed()) { NRF_MPU->DISABLEINDEBUG = MPU_DISABLEINDEBUG_DISABLEINDEBUG_Disabled << MPU_DISABLEINDEBUG_DISABLEINDEBUG_Pos; } // Start the external 32khz crystal oscillator. init_clock(); }
void SystemInit(void) { //Write the necessary UICR and FWID values if needed if (NRF_UICR->CLENR0 == 0xFFFFFFFF) { NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos); while (NRF_NVMC->READY == NVMC_READY_READY_Busy) { } NRF_UICR->CLENR0 = 0x14000; while (NRF_NVMC->READY == NVMC_READY_READY_Busy) { } //write FWID (NRF_UICR->FWID is readonly) *(uint32_t *)0x10001010 = 0xFFFF0049; while (NRF_NVMC->READY == NVMC_READY_READY_Busy) { } NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos); while (NRF_NVMC->READY == NVMC_READY_READY_Busy) { } NVIC_SystemReset(); while (true) { } } // Prepare the peripherals for use as indicated by the PAN 26 "System: Manual setup is required // to enable the use of peripherals" found at Product Anomaly document for your device found at // https://www.nordicsemi.com/. The side effect of executing these instructions in the devices // that do not need it is that the new peripherals in the second generation devices (LPCOMP for // example) will not be available. if (is_manual_peripheral_setup_needed()) { *(uint32_t volatile *)0x40000504 = 0xC007FFDF; *(uint32_t volatile *)0x40006C18 = 0x00008000; } // Disable PROTENSET registers under debug, as indicated by PAN 59 "MPU: Reset value of DISABLEINDEBUG // register is incorrect" found at Product Anomaly document four your device found at // https://www.nordicsemi.com/. There is no side effect of using these instruction if not needed. if (is_disabled_in_debug_needed()) { NRF_MPU->DISABLEINDEBUG = MPU_DISABLEINDEBUG_DISABLEINDEBUG_Disabled << MPU_DISABLEINDEBUG_DISABLEINDEBUG_Pos; } // Start 16 MHz crystal oscillator. NRF_CLOCK->EVENTS_HFCLKSTARTED = 0; NRF_CLOCK->TASKS_HFCLKSTART = 1; // Wait for the external oscillator to start up. while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) { // Do nothing. } }
void SystemInit(void) { #if defined(TARGET_NRF_32MHZ_XTAL) /* For 32MHz HFCLK XTAL such as Taiyo Yuden Physically, tiny footprint XTAL oscillate higher freq. To make BLE modules smaller, some modules are using 32MHz XTAL. This code wriging the value 0xFFFFFF00 to the UICR (User Information Configuration Register) at address 0x10001008, to make nRF51 works with 32MHz system clock. This register will be overwritten by SoftDevice to 0xFFFFFFFF, the default value. Each hex files built with mbed classic online compiler contain SoftDevice, so that, this code run once just after the hex file will be flashed onto nRF51. After changing the value, nRF51 need to reboot. */ if (*(uint32_t *)0x10001008 == 0xFFFFFFFF) { NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} *(uint32_t *)0x10001008 = 0xFFFFFF00; NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} NVIC_SystemReset(); while (true){} } #endif /* If desired, switch off the unused RAM to lower consumption by the use of RAMON register. It can also be done in the application main() function. */ /* Prepare the peripherals for use as indicated by the PAN 26 "System: Manual setup is required to enable the use of peripherals" found at Product Anomaly document for your device found at https://www.nordicsemi.com/. The side effect of executing these instructions in the devices that do not need it is that the new peripherals in the second generation devices (LPCOMP for example) will not be available. */ if (is_manual_peripheral_setup_needed()) { *(uint32_t volatile *)0x40000504 = 0xC007FFDF; *(uint32_t volatile *)0x40006C18 = 0x00008000; } /* Disable PROTENSET registers under debug, as indicated by PAN 59 "MPU: Reset value of DISABLEINDEBUG register is incorrect" found at Product Anomaly document four your device found at https://www.nordicsemi.com/. There is no side effect of using these instruction if not needed. */ if (is_disabled_in_debug_needed()) { NRF_MPU->DISABLEINDEBUG = MPU_DISABLEINDEBUG_DISABLEINDEBUG_Disabled << MPU_DISABLEINDEBUG_DISABLEINDEBUG_Pos; } // Start the external 32khz crystal oscillator. init_clock(); }
void SystemInit(void) { /* If desired, switch off the unused RAM to lower consumption by the use of RAMON register. It can also be done in the application main() function. */ /* Prepare the peripherals for use as indicated by the PAN 26 "System: Manual setup is required to enable the use of peripherals" found at Product Anomaly document for your device found at https://www.nordicsemi.com/. The side effect of executing these instructions in the devices that do not need it is that the new peripherals in the second generation devices (LPCOMP for example) will not be available. */ if (is_manual_peripheral_setup_needed()) { *(uint32_t volatile *)0x40000504 = 0xC007FFDF; *(uint32_t volatile *)0x40006C18 = 0x00008000; } /* Disable PROTENSET registers under debug, as indicated by PAN 59 "MPU: Reset value of DISABLEINDEBUG register is incorrect" found at Product Anomaly document four your device found at https://www.nordicsemi.com/. There is no side effect of using these instruction if not needed. */ if (is_disabled_in_debug_needed()) { NRF_MPU->DISABLEINDEBUG = MPU_DISABLEINDEBUG_DISABLEINDEBUG_Disabled << MPU_DISABLEINDEBUG_DISABLEINDEBUG_Pos; } // Start the external 32khz crystal oscillator. #if defined(TARGET_DELTA_DFCM_NNN40) || defined(TARGET_HRM1017) NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos); #else NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos); #endif NRF_CLOCK->EVENTS_LFCLKSTARTED = 0; NRF_CLOCK->TASKS_LFCLKSTART = 1; // Wait for the external oscillator to start up. while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) { // Do nothing. } }
void SystemInit(void) { /* If desired, switch off the unused RAM to lower consumption by the use of RAMON register. It can also be done in the application main() function. */ /* Prepare the peripherals for use as indicated by the PAN 26 "System: Manual setup is required to enable the use of peripherals" found at Product Anomaly document for your device found at https://www.nordicsemi.com/DocLib The side effect of executing these instructions in the devices that do not need it is that the new peripherals in the second generation devices (LPCOMP for example) will not be available. */ if (is_manual_peripheral_setup_needed()) { *(uint32_t volatile *)0x40000504 = 0xC007FFDF; *(uint32_t volatile *)0x40006C18 = 0x00008000; } /* Disable PROTENSET registers under debug, as indicated by PAN 59 "MPU: Reset value of DISABLEINDEBUG register is incorrect" found at Product Anomaly document for your device found at https://www.nordicsemi.com/DocLib There is no side effect of using these instruction if not needed. */ if (is_disabled_in_debug_needed()) { NRF_MPU->DISABLEINDEBUG = MPU_DISABLEINDEBUG_DISABLEINDEBUG_Disabled << MPU_DISABLEINDEBUG_DISABLEINDEBUG_Pos; } /* Execute the following code to eliminate excessive current in sleep mode with RAM retention in nRF51802 devices, as indicated by PAN 76 "System: Excessive current in sleep mode with retention" found at Product Anomaly document for your device found at https://www.nordicsemi.com/DocLib */ if (is_peripheral_domain_setup_needed()){ if (*(uint32_t volatile *)0x4006EC00 != 1){ *(uint32_t volatile *)0x4006EC00 = 0x9375; while (*(uint32_t volatile *)0x4006EC00 != 1){ } } *(uint32_t volatile *)0x4006EC14 = 0xC0; } }