📄 prim_tmr.c
字号:
// OS_TMR_TICK = 250
#if defined(_PIC18) || defined(_PIC18I) // PIC18 Hi-Tech
PR2 = OS_TMR_TICK; // timer tick = 1000 instruction cycles
INTCON = 0xC0;
TMR2IE = 1;
TMR2IF = 0;
T2CON = 0x05;
#if defined(_PIC18)
__CONFIG(2,WDTDIS);
#else
__set_configuration_bits(CONFIG3H, WDT_OFF_3);
#endif
#elif defined(_PIC14) // PIC16 Hi-Tech (14-bit)
OPTION = 0b00000001; // timer tick = 1000 instruction cycles
INTCON = 0b11100000;
__CONFIG(WDTDIS);
#elif defined(_PIC12) // PIC12 Hi-Tech (12-bit)
OPTION = 0xD2; // timer tick = 1000 instruction cycles
TMR0 = 0;
__CONFIG(WDTDIS);
#elif defined(_AVR_) || defined(_GAVR_) // AVR IAR, AVR GCC
TCCR0 = (1 << CS01); // timer tick = 2000 instruction cycles
TIMSK |= (1 << TOIE0);
ei(); // enable interrupts
#elif defined(_MSP) // MSP430 IAR
TACCTL1_bit.CCIE = 1; // it is enough of it only for C-Spy needs
ei(); // adjust the timer settings for real work
#elif defined(_51_) // 8x51 Keil
TMOD = 0x00; // timer tick = 8096 instruction cycles
TCON = 0x10;
EA = 1;
ET0 = 1;
#elif defined(_ARM_)
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -