TIMER0.c 1.98 KB
Newer Older
崔立宝's avatar
崔立宝 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
/******************************************************************************
文 件 名:TIMER0.c
功能描述:输入捕获函数
参    数:dutyCycle 占空比
******************************************************************************/
/*
#include "TIMER0.h"

uint32_t CurTime;
uint32_t LastTime;     
uint32_t TimerCycle;
uint8_t  dutyCycle;
uint8_t  timer0status;
uint32_t  pwmcnt;
uint16_t  Espeed;

void TIMER0_INIT(void)   //TIMER0
{
  PTTRR_PTTRR1     = 1;   /* Route IOC1_7 to PR3                                     */
 // TIM1_TSCR1_TEN   = 0;   /* Disable timer module before adjusting registers.        */
 // TIM1_TIOS_IOS7   = 0;   /* Set Channel 7 as input capture.                         */
 // TIM1_TCTL3_EDG7A = 1;   /* Set channel 7 to capture any edge transition.           */
//  TIM1_TCTL3_EDG7B = 1;   /* Set channel 7 to capture any edge transition.           */
 // TIM1_TIE_C7I     = 1;   /* Enable channel 7 interrupt, handled by function TIM1ISR.*/
 // TIM1_TSCR1_TSWAI = 1;   /* Disables the timer module while in wait mode.           */
 // TIM1_TSCR1_TSFRZ = 1;   /* Disables the timer counter while in freeze mode.        */
//  TIM1_TSCR2_PR    = 7;   /* Set prescaler to divide by 16.  分频 1 1 1                   */
 // TIM1_TSCR1_TEN   = 1;   /* Timer Enable.                                           */
//}

//#pragma CODE_SEG __NEAR_SEG NON_BANKED   	//置所有中断函数放在FLASH的非分页区 
/*void  interrupt  Timer0_ONPUT(void)
{
  TIM1_TFLG1_C7F = 1;
  //  pwmcnt++;  //脉冲计数值

  timer0status++;
  if(timer0status == 1)
  {
    CurTime = TIM1_TC7;       //上升沿值
    TIM0_TCTL3_EDG7B = 1;     //初始化下降沿
    TIM0_TCTL3_EDG7A = 0;
  }
  else if(timer0status == 2)
  {
    timer0status = 0;
    LastTime = TIM1_TC7;     //下降沿值
    TIM0_TCTL3_EDG7B = 0;    //初始化上升沿
    TIM0_TCTL3_EDG7A = 1;
    if(LastTime > CurTime)

      TimerCycle = 125000 / (LastTime - CurTime);

    // dutyCycle = TimerCycle/800;
    // dutyCycle= LastTime-CurTime/400;
  }
}
#pragma CODE_SEG DEFAULT
 */