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

關(guān)于本程序的詳細(xì)解說大家可以點(diǎn)擊上圖下載電子書
- #include <msp430x42x.h>
- #include "BasicTimer.h"
- void LED1_Process() /* 任務(wù)1 */
- {
- static unsigned int LED1_Timer;
- LED1_Timer++;
- if(LED1_Timer>=8) {LED1_Timer=0; P1OUT^=BIT1;}
- }
- void LED2_Process() /* 任務(wù)2 */
- {
- static unsigned int LED2_Timer;
- LED2_Timer++;
- if(LED2_Timer>=4) {LED2_Timer=0; P1OUT^=BIT3;}
- }
- void LED3_Process() /* 任務(wù)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; // 配置晶振負(fù)載電容
- P1DIR |= BIT1 + BIT3 + BIT4; // 三個LED所在IO口設(shè)為輸出
- P1OUT =0; // 全滅
- BT_Init(16); // BasicTimer設(shè)為1/16秒中斷一次
- while(1)
- {
- Cpu_SleepWaitBT(); //休眠,等待BT喚醒,以下代碼1/16秒執(zhí)行一次
- LED1_Process(); //LED1閃爍任務(wù)
- LED2_Process(); //LED2閃爍任務(wù)
- LED3_Process(); //LED3閃爍任務(wù)
- }
- }
復(fù)制代碼
|
|