delay.h
资源名称:de8681_w.rar [点击查看]
上传用户:lilishw
上传日期:2021-05-28
资源大小:1542k
文件大小:2k
源码类别:
Modem编程
开发平台:
Visual C++
- //---------------------------------------------------------------------------------------------------
- // Project:- DE8681
- // Filename:- DELAY.H
- // Description:- Header file for DELAY.C
- // Programmer:- D.T.F
- // Version:- 2.0
- // Created:- 28th February 2002
- // Last modified:-
- //---------------------------------------------------------------------------------------------------
- // (C) Consumer Microcircuits Ltd 2002
- //
- // This firmware was designed by:-
- // Consumer Microcircuits Ltd,
- // Langford, Maldon,
- // ESSEX
- // CM9 6WG.
- // in the UK for use with CML evaluation kits only and is based on UK originated technology.
- // Please contact
- // sales@cmlmicro.co.uk
- // +44 (0)1621 875500
- // for licensing details.
- //---------------------------------------------------------------------------------------------------
- /*
- * Delay functions for HI-TECH C on the PIC
- *
- * Functions available:
- * DelayUs(x) Delay specified number of microseconds
- * DelayMs(x) Delay specified number of milliseconds
- * Delay1s(x) Delay specified number of seconds
- *
- * Note that there are range limits: x must not exceed 255 - for xtal
- * frequencies > 12MHz the range for DelayUs is even smaller.
- * To use DelayUs it is only necessary to include this file; to use
- * DelayMs you must include delay.c in your project.
- *
- */
- /* Set the crystal frequency in the CPP predefined symbols list in
- HPDPIC, or on the PICC commmand line, e.g.
- picc -DXTAL_FREQ=4MHZ
- or
- picc -DXTAL_FREQ=100KHZ
- Note that this is the crystal frequency, the CPU clock is
- divided by 4.
- * MAKE SURE this code is compiled with full optimization!!!
- */
- #ifndef XTAL_FREQ
- #define XTAL_FREQ 4MHZ /* Crystal frequency in MHz */
- #endif
- #define MHZ *1000 /* number of kHz in a MHz */
- #define KHZ *1 /* number of kHz in a kHz */
- #if XTAL_FREQ >= 12MHZ
- #define DelayUs(x) { unsigned char _dcnt;
- _dcnt = (x)*((XTAL_FREQ)/12MHZ);
- while(--_dcnt != 0)
- continue; }
- #else
- #define DelayUs(x) { unsigned char _dcnt;
- _dcnt = (x)/(12MHZ/(XTAL_FREQ))|1;
- while(--_dcnt != 0)
- continue; }
- #endif
- extern void DelayMs(unsigned char);
- extern void Delay1s(unsigned char);