?? timer01.c
字號(hào):
/*****************************************************************************
* *
* ********** *
* ************ *
* *** *** *
* *** +++ *** *
* *** + + *** *
* *** + CHIPCON CC1010 EXAMPLE PROGRAM *
* *** + + *** Simple timer demonstration program *
* *** +++ *** *
* *** *** *
* *********** *
* ********* *
* *
*****************************************************************************
* This program demonstrates the use of timers. *
* *
* The program uses timer 0 to generate interrupts at regular intervals *
* (60 msecs). The interrupt service routine resets the timer and toggles *
* the red and the yellow LEDs *
*****************************************************************************
* Author: TEL, JOL *
*****************************************************************************
* Revision history: *
* 1.0 2002/08/29 First Public Release *
* *
* $Log: timer01.c,v $
* Revision 1.3 2003/08/18 12:24:44 tos
* Synchronisation with library update (reentry issue).
*
* Revision 1.2 2002/11/19 15:43:39 kht
* Added startup macros
*
* Revision 1.1 2002/10/14 11:15:15 tos
* Initial version in CVS.
*
* *
****************************************************************************/
#include <chipcon/reg1010.h>
#include <chipcon/cc1010eb.h>
#include <chipcon/hal.h>
ulong timeout;
word tCounter;
//----------------------------------------------------------------------------
// MAIN PROGRAM
//----------------------------------------------------------------------------
void main() {
// Disable watchdog timer
WDT_ENABLE(FALSE);
// Set optimum settings for speed and low power consumption
MEM_NO_WAIT_STATES();
FLASH_SET_POWER_MODE(FLASH_STANDBY_BETWEEN_READS);
// Initialize LEDS
RLED_OE(TRUE); RLED = LED_OFF;
YLED_OE(TRUE); YLED = LED_ON;
// Configure timer 0 to generate an interrupt after 30 msec.
timeout = 30000; // usec
halConfigTimer01(TIMER0 | TIMER01_INT_TIMER, timeout, CC1010EB_CLKFREQ, &tCounter);
INT_ENABLE(INUM_TIMER0, INT_ON);
TIMER0_RUN(TRUE);
INT_GLOBAL_ENABLE(TRUE);
// Loop forever
while (TRUE) {}
} // main
//----------------------------------------------------------------------------
// Timer 0 interrupt service routine:
//----------------------------------------------------------------------------
void TIMER0_ISR() interrupt INUM_TIMER0 {
// Reset the timer to generate another interrupt
INT_SETFLAG (INUM_TIMER0, INT_CLR);
ISR_TIMER0_ADJUST(tCounter);
// Toggle leds
RLED = ~RLED;
YLED = ~YLED;
} // TIMER0_ISR
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -