|
本程序是《MSP430系列單片機系統(tǒng)工程設計與實踐》書里面的源碼,(包含工程文件 )完整例程下載:http://www.torrancerestoration.com/bbs/dpj-46245-1.html

關于本程序的詳細解說大家可以點擊上圖下載電子書
- #include <msp430x42x.h>
- #include "BasicTimer.h"
- void LED1_Process() /* 任務1 */
- {
- static unsigned int LED1_Timer;
- LED1_Timer++;
- if(LED1_Timer>=8) {LED1_Timer=0; P1OUT^=BIT1;}
- }
- void LED2_Process() /* 任務2 */
- {
- static unsigned int LED2_Timer;
- LED2_Timer++;
- if(LED2_Timer>=4) {LED2_Timer=0; P1OUT^=BIT3;}
- }
- void LED3_Process() /* 任務3 */
- {
- static unsigned int LED3_Timer;
- LED3_Timer++;
- if(LED3_Timer>=2) {LED3_Timer=0; P1OUT^=BIT4;}
- }
- void main( void )
- {
- WDTCTL = WDTPW + WDTHOLD; // 停止看門狗
- FLL_CTL0 |= XCAP18PF; // 配置晶振負載電容
- P1DIR |= BIT1 + BIT3 + BIT4; // 三個LED所在IO口設為輸出
- P1OUT =0; // 全滅
- BT_Init(16); // BasicTimer設為1/16秒中斷一次
- while(1)
- {
- Cpu_SleepWaitBT(); //休眠,等待BT喚醒,以下代碼1/16秒執(zhí)行一次
- LED1_Process(); //LED1閃爍任務
- LED2_Process(); //LED2閃爍任務
- LED3_Process(); //LED3閃爍任務
- }
- }
復制代碼
|
|