本帖最后由 gaoyang9992006 于 2023-9-27 10:45 编辑
有朋友说无法用MCC生成的delay函数,我也纳闷,以前是可以用的啊。试了一下,还真是不可用用了。编译时候会说找不到原型。
这个错误通常是没有包含头文件进来,测试了一下,新版的MCC真的没有将这个功能自动纳入到头文件,可以自行添加。
启用DELAY模块后,需要手动添加头文件到程序里。
将头文件手动包含进来即可使用自带的延时函数了。
- #ifndef _DELAY_H
- #define _DELAY_H
- #include <stdint.h>
- /**
- * @ingroup delay
- * [url=home.php?mod=space&uid=247401]@brief[/url] Delays the execution of the program for a certain number of milliseconds
- * @param[in] milliseconds - Number of milliseconds to delay
- * [url=home.php?mod=space&uid=266161]@return[/url] None.
- */
- void DELAY_milliseconds(uint16_t milliseconds);
- /**
- * @ingroup delay
- * [url=home.php?mod=space&uid=247401]@brief[/url] Delays the execution of the program for a certain number of microseconds
- * @param[in] microseconds - Number of microseconds to delay
- * [url=home.php?mod=space&uid=266161]@return[/url] None.
- */
- void DELAY_microseconds(uint16_t microseconds);
- #endif // _DELAY_H
|