timer.c

#include 
#include "utilities.h"
#define TMR0
#define TMR0_MOD1
//#define TMR1
//#define TMR1_MOD1

#if defined (TMR0)
uchar T0RH = 0;
uchar T0RL = 0;
#if defined (TMR0_MOD1)
void setTmr0(uint ms) {
    ulong tmp;

    tmp = 11059200 / 12;
    tmp = tmp * ms / 1000;
    tmp = 65536 - tmp;
    tmp += 28;
    T0RL = tmp;
    T0RH = tmp >> 8;
}
#endif // defined
#endif // defined

#if defined (TMR1)
uchar T1RH = 0;
uchar T1RL = 0;
#if defined (TMR1_MOD1)
void setTmr1(uint ms) {
    ulong tmp;
    tmp = 11059200 / 12;
    tmp = tmp * ms / 1000;
    tmp = 65536 - tmp;
    tmp += 28;
    T1RL = tmp;
    T1RH = tmp >> 8;
}
#endif // defined
#endif // defined



你可能感兴趣的:(51单片机)