system_hc32l130f8ua.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /******************************************************************************
  2. * Copyright (C) 2021, Xiaohua Semiconductor Co., Ltd. All rights reserved.
  3. *
  4. * This software component is licensed by XHSC under BSD 3-Clause license
  5. * (the "License"); You may not use this file except in compliance with the
  6. * License. You may obtain a copy of the License at:
  7. * opensource.org/licenses/BSD-3-Clause
  8. *
  9. ******************************************************************************/
  10. /******************************************************************************
  11. ** @file system_hc32l130f8ua.c
  12. **
  13. ** @brief Headerfile for SYSTEM functions
  14. **
  15. ** @author MADS Team
  16. **
  17. ** - 2022-01-26.
  18. **
  19. ******************************************************************************/
  20. /******************************************************************************/
  21. /* Include files */
  22. /******************************************************************************/
  23. #include "base_types.h"
  24. #include "hc32l130f8ua.h"
  25. #include "system_hc32l130f8ua.h"
  26. /**
  27. ******************************************************************************
  28. ** System Clock Frequency (Core Clock) Variable according CMSIS
  29. ******************************************************************************/
  30. uint32_t SystemCoreClock;
  31. //add clock source.
  32. void SystemCoreClockUpdate (void) // Update SystemCoreClock variable
  33. {
  34. SystemCoreClock = 4000000;
  35. }
  36. /**
  37. ******************************************************************************
  38. ** \brief Setup the microcontroller system. Initialize the System and update
  39. ** the SystemCoreClock variable.
  40. **
  41. ** \param none
  42. ** \return none
  43. ******************************************************************************/
  44. void SystemInit(void)
  45. {
  46. // TODO load trim from flash
  47. //hcr 4MHz manual trim.
  48. M0P_SYSCTRL->RCH_CR_f.TRIM = (*((volatile uint16_t*) (0x00100C08ul))); //Loader 4MHz Trimming value
  49. SystemCoreClockUpdate();
  50. }