本帖最后由 yklstudent 于 2013-3-24 14:22 编辑
hitech picc9.80的sample文件夹下 哪里有delay函数?
我只看到include文件夹下有delays.h头文件
#ifndef __DELAYS_H
#define __DELAYS_H
#if defined(__18CXX) || defined(_PLIB)
/* C18 cycle-count delay routines. */
/* Delay of exactly 1 Tcy */
#define Delay1TCY() _delay(1)
/* Delay of exactly 10 Tcy */
#define Delay10TCY() _delay(10)
/* Delay10TCYx
* Delay multiples of 10 Tcy
* Passing 0 (zero) results in a delay of 2560 cycles.
*/
void Delay10TCYx(unsigned char);
/* Delay100TCYx
* Delay multiples of 100 Tcy
* Passing 0 (zero) results in a delay of 25,600 cycles.
*/
void Delay100TCYx(unsigned char);
/* Delay1KTCYx
* Delay multiples of 1000 Tcy
* Passing 0 (zero) results in a delay of 256,000 cycles.
*/
void Delay1KTCYx(unsigned char);
/* Delay10KTCYx
* Delay multiples of 10,000 Tcy
* Passing 0 (zero) results in a delay of 2,560,000 cycles.
*/
void Delay10KTCYx(unsigned char);
#endif
#endif
这些就是内容 不知道楼主使用其它的版本
还有PICC18头文件也有延时函数
当要先宏定义#define _XTAL_FREQ
才可以调用有关的延时函数
#ifdef _OMNI_CODE_
/****************************************************************/
/* Built-in delay routine */
/****************************************************************/
#pragma inline(_delay)
extern void _delay(unsigned long);
#pragma inline(_delaywdt)
extern void _delaywdt(unsigned long);
#pragma inline(_delay3)
extern void _delay3(unsigned char);
// NOTE: To use the macros below, YOU must have previously defined _XTAL_FREQ
#define __delay_us(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000000.0)))
#define __delay_ms(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000.0)))
#define __delaywdt_us(x) _delaywdt((unsigned long)((x)*(_XTAL_FREQ/4000000.0)))
#define __delaywdt_ms(x) _delaywdt((unsigned long)((x)*(_XTAL_FREQ/4000.0)))
#endif
|