[PIC®/AVR®/dsPIC®产品] 如何使用MCC的delay函数

[复制链接]
9615|4
 楼主| gaoyang9992006 发表于 2023-9-27 10:43 | 显示全部楼层 |阅读模式
本帖最后由 gaoyang9992006 于 2023-9-27 10:45 编辑

有朋友说无法用MCC生成的delay函数,我也纳闷,以前是可以用的啊。试了一下,还真是不可用用了。编译时候会说找不到原型。
这个错误通常是没有包含头文件进来,测试了一下,新版的MCC真的没有将这个功能自动纳入到头文件,可以自行添加。
启用DELAY模块后,需要手动添加头文件到程序里。

将头文件手动包含进来即可使用自带的延时函数了。
  1. #ifndef _DELAY_H
  2. #define _DELAY_H

  3. #include <stdint.h>

  4. /**
  5. *  @ingroup delay
  6. *  [url=home.php?mod=space&uid=247401]@brief[/url] Delays the execution of the program for a certain number of milliseconds
  7. *  @param[in] milliseconds - Number of milliseconds to delay
  8. *  [url=home.php?mod=space&uid=266161]@return[/url] None.
  9. */
  10. void DELAY_milliseconds(uint16_t milliseconds);

  11. /**
  12. *  @ingroup delay
  13. *  [url=home.php?mod=space&uid=247401]@brief[/url] Delays the execution of the program for a certain number of microseconds
  14. *  @param[in] microseconds - Number of microseconds to delay
  15. *  [url=home.php?mod=space&uid=266161]@return[/url] None.
  16. */
  17. void DELAY_microseconds(uint16_t microseconds);

  18. #endif        // _DELAY_H



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
 楼主| gaoyang9992006 发表于 2023-9-27 10:44 | 显示全部楼层
你学会了吗
hjl2832 发表于 2023-10-8 08:26 | 显示全部楼层
这个还真没注意,不过好像我用AVR时没这个问题
heisexingqisi 发表于 2023-10-9 20:16 | 显示全部楼层
会不会是某个版本升级后的BUG。
heisexingqisi 发表于 2023-10-9 20:49 | 显示全部楼层
试了,新版本的可以自动添加这个头文件。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:如果你觉得我的分享或者答复还可以,请给我点赞,谢谢。

2052

主题

16403

帖子

222

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