[方案相关] HC32 启动初始化配置

[复制链接]
1437|5
 楼主| 鱿鱼丝 发表于 2023-5-26 10:56 | 显示全部楼层 |阅读模式
配置ddl_config.h

官方提供的库函数中有ddl_config.h文件,改文件是管理库函数是否加载配置文件。部分内容如下:


  1. /*******************************************************************************
  2. * Global pre-processor symbols/macros ('#define')
  3. ******************************************************************************/
  4. /* Chip module on-off define */
  5. #define DDL_ON                                      (1U)
  6. #define DDL_OFF                                     (0U)

  7. /**
  8. * [url=home.php?mod=space&uid=247401]@brief[/url] This is the list of modules to be used in the Device Driver Library.
  9. * Select the modules you need to use to DDL_ON.
  10. * [url=home.php?mod=space&uid=536309]@NOTE[/url] DDL_ICG_ENABLE must be turned on(DDL_ON) to ensure that the chip works
  11. * properly.
  12. * @note DDL_UTILITY_ENABLE must be turned on(DDL_ON) if using Device Driver
  13. * Library.
  14. * @note DDL_PRINT_ENABLE must be turned on(DDL_ON) if using printf function.
  15. */
  16. #define DDL_ICG_ENABLE                              (DDL_ON)
  17. #define DDL_UTILITY_ENABLE                          (DDL_ON)
  18. #define DDL_PRINT_ENABLE                            (DDL_OFF)
  19. ……省略……


评论

———————————————— 版权声明:本文为CSDN博主「南国红枫叶」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/zhaopenglihui/article/details/118056850  发表于 2023-5-26 10:59
 楼主| 鱿鱼丝 发表于 2023-5-26 10:59 | 显示全部楼层
在使用到相关的库函数时将对应的地方配置为DLL_ON。
 楼主| 鱿鱼丝 发表于 2023-5-26 10:59 | 显示全部楼层
初始化配置( ICG)
芯片复位解除后,硬件电路会读取 FLASH 地址0x00000400H ~0x0000045FH 把数据加载到初始化配置寄存器。地址 0x00000410H~0x0000045FH 为预约功能,请写入全 1 保证芯片正常动作。
在添加官方提供的DLL库后,相关的配置在hc32f4a0_icg.c 文件中可以看到相关的配置。
 楼主| 鱿鱼丝 发表于 2023-5-26 11:00 | 显示全部楼层
/**
* @brief ICG parameters configuration
*/
/* The ICG area is filled with F by default, HRC = 16MHZ,
    Please modify this value as required */
#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
const uint32_t u32ICG[] __attribute__((section(".ARM.__at_0x400"))) =
#elif defined (__GNUC__) && !defined (__CC_ARM)
const uint32_t u32ICG[] __attribute__((section(".icg_sec"))) =
#elif defined (__CC_ARM)
const uint32_t u32ICG[] __attribute__((at(0x400))) =
#elif defined (__ICCARM__)
#pragma location = 0x400
__root static const uint32_t u32ICG[] =
#else
#error "unsupported compiler!!"
#endif
{
    /* ICG 0~3 */
    0xFFFFFFFFUL,
    0xFFFFFFFFUL,
    0xFFFFFFFFUL,
    0xFFFFFFFFUL,
    /* Reserved 0~3 */
    0xFFFFFFFFUL,
    0xFFFFFFFFUL,
    0xFFFFFFFFUL,
    0xFFFFFFFFUL,
    /* Reserved 4~7 */
    0xFFFFFFFFUL,
    0xFFFFFFFFUL,
    0xFFFFFFFFUL,
    0xFFFFFFFFUL,
    /* Reserved 8~11 */
    0xFFFFFFFFUL,
    0xFFFFFFFFUL,
    0xFFFFFFFFUL,
    0xFFFFFFFFUL,
    /* Reserved 12~15 */
    0xFFFFFFFFUL,
    0xFFFFFFFFUL,
    0xFFFFFFFFUL,
    0xFFFFFFFFUL,
    /* Reserved 16~19 */
    0xFFFFFFFFUL,
    0xFFFFFFFFUL,
    0xFFFFFFFFUL,
    0xFFFFFFFFUL,
};
 楼主| 鱿鱼丝 发表于 2023-5-26 11:00 | 显示全部楼层
如果在库函数配置文件中 #define DDL_ICG_ENABLE (DDL_OFF)时,编译后的程序下载到板子上也不会运行。解决办法有两种:

在配置文件中直接打开 #define DDL_ICG_ENABLE (DDL_ON)
在main.c 的文件中添加上面的配置代码,在编译时,程序最后会将相关内容链接到400H地址。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

47

主题

480

帖子

2

粉丝
快速回复 在线客服 返回列表 返回顶部