?? timer.c
字號:
#include "msp430x12x2.h"
/***************************************************/
//timerA's init and delay functions
unsigned int RND[40] = {3896,3116,4676,3896,3216,4576,3896,3316,4476,3896, 4676,3116,3896,4576,3216,
3896,4576,3216,3896,3316,4476,3896, 4676,3116,3896,3216,4576,3896,3116,4676,
3896,4376,3616,3896,3216,4176,3896, 4676,3516,3896};
extern unsigned char counter;
void delayNms (unsigned int n)
{
unsigned int count,buff;
for(count=0; count<n; count++)
{
CCR0 = 33-1;
TACTL = TASSEL_1 + MC_1; // ACLK, upmode
do
{
buff = TACTL & 0x01;
}while(buff == 0);
TACTL = MC_0 + TACLR; //stop the timerA
}
}
void delay300us (void)
{
unsigned int buff;
CCR0 = 11-1;
TACTL = TASSEL_1 + MC_1 ; // ACLK, upmode
do
{
buff = TACTL & 0x01;
}while(buff == 0);
TACTL = MC_0 + TACLR; //stop the timerA
}
void delay30us (void)
{
unsigned int buff;
CCR0 = 1;
TACTL = TASSEL_1 + MC_1 ; // ACLK, upmode
do
{
buff = TACTL & 0x01;
}while(buff == 0);
TACTL = MC_0 + TACLR; //stop the timerA
}
void initTimerA(void)
{
CCTL0 = CCIE; // CCR0 interrupt enabled
TACTL = MC_0 + TACLR;
CCR0 = RND[counter]-1;
TACTL = TASSEL_1 + MC_1 + ID_3; // ACLK, upmode
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -