?? int_timers.c
字號(hào):
/*****************************************************************************
* *
* ********** *
* ************ *
* *** *** *
* *** +++ *** *
* *** + + *** *
* *** + CHIPCON CC1010 EXAMPLE PROGRAM *
* *** + + *** TIMER INTERRUPTS *
* *** +++ *** *
* *** *** *
* *********** *
* ********* *
* *
*****************************************************************************
* Demonstrates the CC1010 timer interrupt sources. Uses: *
* - halConfigTimer01, halConfigTimer23 functions *
* - INT_ENABLE, INT_PRIORITY, INT_GLOBAL_ENABLE, INT_SETFLAG macros *
* - TIMER0_RUN, TIMER1_RUN, TIMER2_RUN, TIMER3_RUN macros *
* - ISR_TIMER0_ADJUST, ISR_TIMER1_ADJUST macros *
* *
* The program cannot be run with single-step operation in the debugger, *
* because the debugger's use of interrupts interfere with the operation. *
* *
* The timers 0-3 are set up and run. Each of the 4 interrupt routines *
* lights up one of the LEDs. *
*****************************************************************************
* Author: ARR *
*****************************************************************************
* Revision history: *
* 1.0 2002/08/29 First public release *
* *
* $Log: int_timers.c,v $
* Revision 1.2 2002/11/18 10:55:32 kht
* Added startup macros
*
* Revision 1.1 2002/10/11 15:06:45 tos
* Initial version in CVS.
*
* *
****************************************************************************/
#include <chipcon/hal.h>
#include <chipcon/cc1010eb.h>
// Timer value in XRAM
word xdata timer0_val;
word xdata timer1_val;
// Other global variables for the test
bool timer0_checked = FALSE;
bool timer1_checked = FALSE;
bool timer2_checked = FALSE;
bool timer3_checked = FALSE;
int main() {
// Disable watchdog timer
WDT_ENABLE(FALSE);
// Startup macros for speed and low power consumption
MEM_NO_WAIT_STATES();
FLASH_SET_POWER_MODE(FLASH_STANDBY_BETWEEN_READS);
// All I/Os are inputs after reset. Make I/Os connected to LEDs outputs
RLED=YLED=GLED=BLED=LED_OFF;
RLED_OE(TRUE); YLED_OE(TRUE); GLED_OE(TRUE); BLED_OE(TRUE);
// Set up timer 0 as an interrupt timer w/ max period
halConfigTimer01(TIMER0 | TIMER01_INT_TIMER, 0, CC1010EB_CLKFREQ, &timer0_val);
// Setup timer 0 as an interrupt source
INT_ENABLE(INUM_TIMER0, INT_ON);
INT_PRIORITY(INUM_TIMER0, INT_HIGH);
// Set up timer 1 as an interrupt timer w/ max period
halConfigTimer01(TIMER1 | TIMER01_INT_TIMER, 0, CC1010EB_CLKFREQ, &timer1_val);
// Setup timer 1 as an interrupt source
INT_ENABLE(INUM_TIMER1, INT_ON);
INT_PRIORITY(INUM_TIMER1, INT_LOW);
// Set up timer 2 as an interrupt timer w/ max period
halConfigTimer23(TIMER2 | TIMER23_INT_TIMER, 0, CC1010EB_CLKFREQ);
// Setup timer 2 as an interrupt source
INT_ENABLE(INUM_TIMER2, INT_ON);
INT_PRIORITY(INUM_TIMER2, INT_HIGH);
// Set up timer 3 as an interrupt timer w/ max period
halConfigTimer23(TIMER3 | TIMER23_INT_TIMER, 0, CC1010EB_CLKFREQ);
// Setup timer 3 as an interrupt source
INT_ENABLE(INUM_TIMER3, INT_ON);
INT_PRIORITY(INUM_TIMER3, INT_LOW);
// Turn on interrupts
INT_GLOBAL_ENABLE(INT_ON);
// Test timer 0 interrupt
TIMER0_RUN(TRUE);
while(!timer0_checked);
TIMER0_RUN(FALSE);
// Test timer 1 interrupt
TIMER1_RUN(TRUE);
while(!timer1_checked);
TIMER1_RUN(FALSE);
// Test timer 2 interrupt
TIMER2_RUN(TRUE);
while(!timer2_checked);
TIMER2_RUN(FALSE);
// Test timer 3 interrupt
TIMER3_RUN(TRUE);
while(!timer3_checked);
TIMER3_RUN(FALSE);
// Infinite loop
while(1);
}
// ISR (interrupt service routine) for timer 0, priority 2
// The interrupt is cleared by hardware
void isr_timer0() interrupt INUM_TIMER0 {
ISR_TIMER0_ADJUST(timer0_val);
BLED=LED_ON;
timer0_checked = TRUE;
} //end isr_timer0()
// ISR (interrupt service routine) for timer 1, priority 4
// The interrupt is cleared by hardware
void isr_timer1() interrupt INUM_TIMER1 {
ISR_TIMER1_ADJUST(timer1_val);
GLED=LED_ON;
timer1_checked = TRUE;
} //end isr_timer1()
// ISR (interrupt service routine) for timer 2, priority 8
// The interrupt must be cleared by software
void isr_timer2() interrupt INUM_TIMER2 {
INT_SETFLAG(INUM_TIMER2, INT_CLR);
YLED=LED_ON;
timer2_checked = TRUE;
} //end isr_timer2()
// ISR (interrupt service routine) for timer 3, priority 10
// The interrupt must be cleared by software
void isr_timer3() interrupt INUM_TIMER3 {
INT_SETFLAG(INUM_TIMER3, INT_CLR);
RLED=LED_ON;
timer3_checked = TRUE;
} //end isr_timer3()
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -