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

📄 timer.c

📁 射频识别利用nrf 2401芯片实现收发功能
💻 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 + -