system_MIMXRT1176_cm7.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. ** ###################################################################
  3. ** Processors: MIMXRT1176AVM8A_cm7
  4. ** MIMXRT1176CVM8A_cm7
  5. ** MIMXRT1176DVMAA_cm7
  6. **
  7. ** Compilers: Freescale C/C++ for Embedded ARM
  8. ** GNU C Compiler
  9. ** IAR ANSI C/C++ Compiler for ARM
  10. ** Keil ARM C/C++ Compiler
  11. ** MCUXpresso Compiler
  12. **
  13. ** Reference manual: IMXRT1170RM, Rev 1, 02/2021
  14. ** Version: rev. 1.0, 2020-12-29
  15. ** Build: b210615
  16. **
  17. ** Abstract:
  18. ** Provides a system configuration function and a global variable that
  19. ** contains the system frequency. It configures the device and initializes
  20. ** the oscillator (PLL) that is part of the microcontroller device.
  21. **
  22. ** Copyright 2016 Freescale Semiconductor, Inc.
  23. ** Copyright 2016-2021 NXP
  24. ** All rights reserved.
  25. **
  26. ** SPDX-License-Identifier: BSD-3-Clause
  27. **
  28. ** http: www.nxp.com
  29. ** mail: support@nxp.com
  30. **
  31. ** Revisions:
  32. ** - rev. 0.1 (2018-03-05)
  33. ** Initial version.
  34. ** - rev. 1.0 (2020-12-29)
  35. ** Update header files to align with IMXRT1170RM Rev.0.
  36. **
  37. ** ###################################################################
  38. */
  39. /*!
  40. * @file MIMXRT1176_cm7
  41. * @version 1.0
  42. * @date 2021-06-15
  43. * @brief Device specific configuration file for MIMXRT1176_cm7 (implementation
  44. * file)
  45. *
  46. * Provides a system configuration function and a global variable that contains
  47. * the system frequency. It configures the device and initializes the oscillator
  48. * (PLL) that is part of the microcontroller device.
  49. */
  50. #include <stdint.h>
  51. #include "fsl_device_registers.h"
  52. /* ----------------------------------------------------------------------------
  53. -- Core clock
  54. ---------------------------------------------------------------------------- */
  55. uint32_t SystemCoreClock = DEFAULT_SYSTEM_CLOCK;
  56. /* ----------------------------------------------------------------------------
  57. -- SystemInit()
  58. ---------------------------------------------------------------------------- */
  59. void SystemInit (void) {
  60. #if ((__FPU_PRESENT == 1) && (__FPU_USED == 1))
  61. SCB->CPACR |= ((3UL << 10*2) | (3UL << 11*2)); /* set CP10, CP11 Full Access */
  62. #endif /* ((__FPU_PRESENT == 1) && (__FPU_USED == 1)) */
  63. #if defined(__MCUXPRESSO)
  64. extern uint32_t g_pfnVectors[]; // Vector table defined in startup code
  65. SCB->VTOR = (uint32_t)g_pfnVectors;
  66. #endif
  67. /* Watchdog disable */
  68. #if (DISABLE_WDOG)
  69. if ((WDOG1->WCR & WDOG_WCR_WDE_MASK) != 0U)
  70. {
  71. WDOG1->WCR &= ~(uint16_t) WDOG_WCR_WDE_MASK;
  72. }
  73. if ((WDOG2->WCR & WDOG_WCR_WDE_MASK) != 0U)
  74. {
  75. WDOG2->WCR &= ~(uint16_t) WDOG_WCR_WDE_MASK;
  76. }
  77. if ((RTWDOG3->CS & RTWDOG_CS_CMD32EN_MASK) != 0U)
  78. {
  79. RTWDOG3->CNT = 0xD928C520U; /* 0xD928C520U is the update key */
  80. }
  81. else
  82. {
  83. RTWDOG3->CNT = 0xC520U;
  84. RTWDOG3->CNT = 0xD928U;
  85. }
  86. RTWDOG3->TOVAL = 0xFFFF;
  87. RTWDOG3->CS = (uint32_t) ((RTWDOG3->CS) & ~RTWDOG_CS_EN_MASK) | RTWDOG_CS_UPDATE_MASK;
  88. if ((RTWDOG4->CS & RTWDOG_CS_CMD32EN_MASK) != 0U)
  89. {
  90. RTWDOG4->CNT = 0xD928C520U; /* 0xD928C520U is the update key */
  91. }
  92. else
  93. {
  94. RTWDOG4->CNT = 0xC520U;
  95. RTWDOG4->CNT = 0xD928U;
  96. }
  97. RTWDOG4->TOVAL = 0xFFFF;
  98. RTWDOG4->CS = (uint32_t) ((RTWDOG4->CS) & ~RTWDOG_CS_EN_MASK) | RTWDOG_CS_UPDATE_MASK;
  99. #endif /* (DISABLE_WDOG) */
  100. /* Disable Systick which might be enabled by bootrom */
  101. if ((SysTick->CTRL & SysTick_CTRL_ENABLE_Msk) != 0U)
  102. {
  103. SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
  104. }
  105. /* Enable instruction and data caches */
  106. #if defined(__ICACHE_PRESENT) && __ICACHE_PRESENT
  107. if (SCB_CCR_IC_Msk != (SCB_CCR_IC_Msk & SCB->CCR)) {
  108. SCB_EnableICache();
  109. }
  110. #endif
  111. /* Clear bit 13 to its reset value since it might be set by ROM. */
  112. IOMUXC_GPR->GPR28 &= ~IOMUXC_GPR_GPR28_CACHE_USB_MASK;
  113. #if defined(ROM_ECC_ENABLED)
  114. /* When ECC is enabled, SRC->SRSR need to be cleared since only correct SRSR value can trigger ROM ECC preload procedure.
  115. Save SRSR to SRC->GPR[10] so that application can still check SRSR value from SRC->GPR[10]. */
  116. SRC->GPR[10] = SRC->SRSR;
  117. /* clear SRSR */
  118. SRC->SRSR = 0xFFFFFFFFU;
  119. #endif
  120. /* Enable entry to thread mode when divide by zero */
  121. SCB->CCR |= SCB_CCR_DIV_0_TRP_Msk;
  122. __DSB();
  123. __ISB();
  124. SystemInitHook();
  125. }
  126. /* ----------------------------------------------------------------------------
  127. -- SystemCoreClockUpdate()
  128. ---------------------------------------------------------------------------- */
  129. void SystemCoreClockUpdate (void) {
  130. /* TBD */
  131. }
  132. /* ----------------------------------------------------------------------------
  133. -- SystemInitHook()
  134. ---------------------------------------------------------------------------- */
  135. __attribute__ ((weak)) void SystemInitHook (void) {
  136. /* Void implementation of the weak function. */
  137. }