⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 settimer34period.c

📁 无线单片机CC1110的一些使用源代码
💻 C
字号:
/******************************************************************************
*                                                                             *
*    ****       ******       ****
*     ****     ********     ****
*      ****   ****  ****   ****
*       **** ****    **** ****              wxl
*        *******      *******
*         *****        *****                    成都无线龙通讯科技有限公司
*                                                                             *
*******************************************************************************

Filename:     uart.c                          文 件 名:      uart.c
Target:       cc1110                          使用芯片:       cc1110
Author:       WXL                             程 序 员:      无线龙
data:         1/12-2007                       日    期:      1/12-2007
******************************************************************************/
/**********************************头文件**************************************/
#include "hal.h"


//------------------------------------------------------------------------------------------------------
// See hal.h for a description of this function.
//------------------------------------------------------------------------------------------------------
BYTE halSetTimer34Period(BYTE timer, DWORD period){

        BYTE div = 0;

        if(TICKSPD > 5) { // Checking that the period is not too short.
        if( (period < 2*(TICKSPD-5)) && (period != 0) ){
               return 0;
           }
    }

        if(period == 0){  // If period is 0, max period length and max prescaler
                div = 7;  // division is used.
                period = 255;
        } else {
                period = ((period*26) >> TICKSPD);// Determining how many timer ticks the period consist of
                while(period > 255){              // If the period is too long, the prescaler division is
                        period = (period >> 1);   // increased.
                        div++;
                        if(div > 7){              // If the period is too long when using max prescaler division,
                                return 0;         // 0 is returned.
                        }
                }
        }

        if(timer == 4){
                // Timer 4 selected
                T4CTL |= (div << 5);              // Setting prescaler value
                T4CC0 = (BYTE) period;            // Setting timer value.
        } else if(timer == 3){
                // Timer 3 selected
                T3CTL |= (div << 5);              // Setting prescaler value
                T3CC0 = (BYTE) period;            // Setting timer value.
        } else {return 0;}

        return period;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -