打印
[DSP编程]

ECAP产生APWM

[复制链接]
1207|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
lzx18570633112|  楼主 | 2019-8-3 21:58 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

这是ECAP文件配置的程序:

// TI File $Revision: /main/2 $
// Checkin $Date: March 15, 2007   16:54:36 $
//###########################################################################
//
// FILE:   DSP2833x_ECap.c
//
// TITLE:  DSP2833x eCAP Initialization & Support Functions.
//
//###########################################################################
// $TI Release: DSP2833x/DSP2823x C/C++ Header Files V1.31 $
// $Release Date: August 4, 2009 $
//###########################################################################

#include "DSP2833x_Device.h"     // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h"   // DSP2833x Examples Include File

//---------------------------------------------------------------------------
// InitECap:
//---------------------------------------------------------------------------
// This function initializes the eCAP(s) to a known state.
//
void InitECap(void)
{
   // Initialize eCAP1/2/3

   //tbd...

}

//---------------------------------------------------------------------------
// Example: InitECapGpio:
//---------------------------------------------------------------------------
// This function initializes GPIO pins to function as ECAP pins
//
// Each GPIO pin can be configured as a GPIO pin or up to 3 different
// peripheral functional pins. By default all pins come up as GPIO
// inputs after reset.
//
// Caution:
// For each eCAP peripheral
// Only one GPIO pin should be enabled for ECAP operation.
// Comment out other unwanted lines.

void InitECapGpio()
{

   InitECap1Gpio();
#if (DSP28_ECAP2)
   InitECap2Gpio();
#endif // endif DSP28_ECAP2
#if (DSP28_ECAP3)
   InitECap3Gpio();
#endif // endif DSP28_ECAP3
#if (DSP28_ECAP4)
   InitECap4Gpio();
#endif // endif DSP28_ECAP4
#if (DSP28_ECAP5)
   InitECap5Gpio();
#endif // endif DSP28_ECAP5
#if (DSP28_ECAP6)
   InitECap6Gpio();
#endif // endif DSP28_ECAP6
}

void InitECap1Gpio(void)
{
   EALLOW;
/* Enable internal pull-up for the selected pins */
// Pull-ups can be enabled or disabled by the user.
// This will enable the pullups for the specified pins.
// Comment out other unwanted lines.

// GpioCtrlRegs.GPAPUD.bit.GPIO5 = 0;      // Enable pull-up on GPIO5 (CAP1)
   GpioCtrlRegs.GPAPUD.bit.GPIO24 = 1;     // Disable pull-up on GPIO24 (CAP1)
// GpioCtrlRegs.GPBPUD.bit.GPIO34 = 0;     // Enable pull-up on GPIO34 (CAP1)


// Inputs are synchronized to SYSCLKOUT by default.
// Comment out other unwanted lines.

// GpioCtrlRegs.GPAQSEL1.bit.GPIO5 = 0;    // Synch to SYSCLKOUT GPIO5 (CAP1)
   GpioCtrlRegs.GPAQSEL2.bit.GPIO24 = 0;   // Synch to SYSCLKOUT GPIO24 (CAP1)
// GpioCtrlRegs.GPBQSEL1.bit.GPIO34 = 0;   // Synch to SYSCLKOUT GPIO34 (CAP1)

/* Configure eCAP-1 pins using GPIO regs*/
// This specifies which of the possible GPIO pins will be eCAP1 functional pins.
// Comment out other unwanted lines.

// GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 3;     // Configure GPIO5 as CAP1
   GpioCtrlRegs.GPAMUX2.bit.GPIO24 = 1;    // Configure GPIO24 as CAP1
// GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 1;    // Configure GPIO24 as CAP1

    EDIS;
}

#if DSP28_ECAP2
void InitECap2Gpio(void)
{
   EALLOW;
/* Enable internal pull-up for the selected pins */
// Pull-ups can be enabled or disabled by the user.
// This will enable the pullups for the specified pins.
// Comment out other unwanted lines.

//   GpioCtrlRegs.GPAPUD.bit.GPIO7 = 0;     // Enable pull-up on GPIO7 (CAP2)
   GpioCtrlRegs.GPAPUD.bit.GPIO25 = 0;    // Enable pull-up on GPIO25 (CAP2)
// GpioCtrlRegs.GPBPUD.bit.GPIO37 = 0;    // Enable pull-up on GPIO37 (CAP2)

// Inputs are synchronized to SYSCLKOUT by default.
// Comment out other unwanted lines.

//  GpioCtrlRegs.GPAQSEL1.bit.GPIO7 = 0;    // Synch to SYSCLKOUT GPIO7 (CAP2)
   GpioCtrlRegs.GPAQSEL2.bit.GPIO25 = 0;   // Synch to SYSCLKOUT GPIO25 (CAP2)
// GpioCtrlRegs.GPBQSEL1.bit.GPIO37 = 0;   // Synch to SYSCLKOUT GPIO37 (CAP2)

/* Configure eCAP-2 pins using GPIO regs*/
// This specifies which of the possible GPIO pins will be eCAP2 functional pins.
// Comment out other unwanted lines.

//   GpioCtrlRegs.GPAMUX1.bit.GPIO7 = 3;    // Configure GPIO7 as CAP2
   GpioCtrlRegs.GPAMUX2.bit.GPIO25 = 1;   // Configure GPIO25 as CAP2
// GpioCtrlRegs.GPBMUX1.bit.GPIO37 = 3;   // Configure GPIO37 as CAP2

    EDIS;
}
#endif // endif DSP28_ECAP2

#if DSP28_ECAP3
void InitECap3Gpio(void)
{
   EALLOW;

/* Enable internal pull-up for the selected pins */
// Pull-ups can be enabled or disabled by the user.
// This will enable the pullups for the specified pins.
// Comment out other unwanted lines.

//   GpioCtrlRegs.GPAPUD.bit.GPIO9 = 0;      // Enable pull-up on GPIO9 (CAP3)
   GpioCtrlRegs.GPAPUD.bit.GPIO26 = 0;     // Enable pull-up on GPIO26 (CAP3)

// Inputs are synchronized to SYSCLKOUT by default.
// Comment out other unwanted lines.

//   GpioCtrlRegs.GPAQSEL1.bit.GPIO9 = 0;    // Synch to SYSCLKOUT GPIO9 (CAP3)
   GpioCtrlRegs.GPAQSEL2.bit.GPIO26 = 0;   // Synch to SYSCLKOUT GPIO26 (CAP3)

/* Configure eCAP-3 pins using GPIO regs*/
// This specifies which of the possible GPIO pins will be eCAP3 functional pins.
// Comment out other unwanted lines.

//   GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 3;     // Configure GPIO9 as CAP3
   GpioCtrlRegs.GPAMUX2.bit.GPIO26 = 1;    // Configure GPIO26 as CAP3

    EDIS;
}
#endif // endif DSP28_ECAP3


#if DSP28_ECAP4
void InitECap4Gpio(void)
{
   EALLOW;

/* Enable internal pull-up for the selected pins */
// Pull-ups can be enabled or disabled by the user.
// This will enable the pullups for the specified pins.
// Comment out other unwanted lines.

   GpioCtrlRegs.GPAPUD.bit.GPIO11 = 0;   // Enable pull-up on GPIO11 (CAP4)
// GpioCtrlRegs.GPAPUD.bit.GPIO27 = 0;   // Enable pull-up on GPIO27 (CAP4)

// Inputs are synchronized to SYSCLKOUT by default.
// Comment out other unwanted lines.

   GpioCtrlRegs.GPAQSEL1.bit.GPIO11 = 0; // Synch to SYSCLKOUT GPIO11 (CAP4)
// GpioCtrlRegs.GPAQSEL2.bit.GPIO27 = 0; // Synch to SYSCLKOUT GPIO27 (CAP4)

/* Configure eCAP-4 pins using GPIO regs*/
// This specifies which of the possible GPIO pins will be eCAP4 functional pins.
// Comment out other unwanted lines.

   GpioCtrlRegs.GPAMUX1.bit.GPIO11 = 3;  // Configure GPIO11 as CAP4
// GpioCtrlRegs.GPAMUX2.bit.GPIO27 = 1;  // Configure GPIO27 as CAP4

    EDIS;
}
#endif // endif DSP28_ECAP4


#if DSP28_ECAP5
void InitECap5Gpio(void)
{
   EALLOW;

/* Enable internal pull-up for the selected pins */
// Pull-ups can be enabled or disabled by the user.
// This will enable the pullups for the specified pins.
// Comment out other unwanted lines.

// GpioCtrlRegs.GPAPUD.bit.GPIO3 = 0;     // Enable pull-up on GPIO3 (CAP5)
   GpioCtrlRegs.GPBPUD.bit.GPIO48 = 1;    // Disable pull-up on GPIO48 (CAP5)

// Inputs are synchronized to SYSCLKOUT by default.
// Comment out other unwanted lines.

// GpioCtrlRegs.GPAQSEL1.bit.GPIO3 = 0;  // Synch to SYSCLKOUT GPIO3 (CAP5)
   GpioCtrlRegs.GPBQSEL2.bit.GPIO48 = 0; // Synch to SYSCLKOUT GPIO48 (CAP5)

/* Configure eCAP-5 pins using GPIO regs*/
// This specifies which of the possible GPIO pins will be eCAP5 functional pins.
// Comment out other unwanted lines.

// GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 2;   // Configure GPIO3 as CAP5
   GpioCtrlRegs.GPBMUX2.bit.GPIO48 = 1;  // Configure GPIO48 as CAP5

    EDIS;
}
#endif // endif DSP28_ECAP5


#if DSP28_ECAP6
void InitECap6Gpio(void)
{
   EALLOW;

/* Enable internal pull-up for the selected pins */
// Pull-ups can be enabled or disabled by the user.
// This will enable the pullups for the specified pins.
// Comment out other unwanted lines.

   GpioCtrlRegs.GPAPUD.bit.GPIO1 = 0;     // Enable pull-up on GPIO1 (CAP6)
// GpioCtrlRegs.GPBPUD.bit.GPIO49 = 0;    // Enable pull-up on GPIO49 (CAP6)

// Inputs are synchronized to SYSCLKOUT by default.
// Comment out other unwanted lines.

   GpioCtrlRegs.GPAQSEL1.bit.GPIO1 = 0;  // Synch to SYSCLKOUT GPIO1 (CAP6)
// GpioCtrlRegs.GPBQSEL2.bit.GPIO49 = 0; // Synch to SYSCLKOUT GPIO49 (CAP6)

/* Configure eCAP-5 pins using GPIO regs*/
// This specifies which of the possible GPIO pins will be eCAP6 functional pins.
// Comment out other unwanted lines.

   GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 2;   // Configure GPIO1 as CAP6
// GpioCtrlRegs.GPBMUX2.bit.GPIO49 = 1;  // Configure GPIO49 as CAP6

    EDIS;
}
#endif // endif DSP28_ECAP6

//===========================================================================
// End of file.
//===========================================================================
这是主函数程序:

//       $Boot_Table:
//         GPIO87   GPIO86     GPIO85   GPIO84
//          XA15     XA14       XA13     XA12
//           PU       PU         PU       PU
//        ==========================================
//            1        1          1        1    Jump to Flash
//            1        1          1        0    SCI-A boot
//            1        1          0        1    SPI-A boot
//            1        1          0        0    I2C-A boot
//            1        0          1        1    eCAN-A boot
//            1        0          1        0    McBSP-A boot
//            1        0          0        1    Jump to XINTF x16
//            1        0          0        0    Jump to XINTF x32
//            0        1          1        1    Jump to OTP
//            0        1          1        0    Parallel GPIO I/O boot
//            0        1          0        1    Parallel XINTF boot
//            0        1          0        0    Jump to SARAM        <- "boot to SARAM"
//            0        0          1        1    Branch to check boot mode
//            0        0          1        0    Boot to flash, bypass ADC cal
//            0        0          0        1    Boot to SARAM, bypass ADC cal
//            0        0          0        0    Boot to SCI-A, bypass ADC cal
//                                              Boot_Table_End$
// DESCRIPTION:
//    This example configures ePWM3A for:
//    - Up count
//    - Period starts at 2 and goes up to 1000
//    - Toggle output on PRD
//    eCAP1 is configured to capture the time between rising
//    and falling edge of the PWM3A output.
//###########################################################################
// $TI Release: DSP2833x/DSP2823x C/C++ Header Files V1.31 $
// $Release Date: August 4, 2009 $
//###########################################################################
#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
#define   PI  3.14159
#define   Radius  0.22
#define      LED1    GpioDataRegs.GPBDAT.bit.GPIO60
#define      LED2    GpioDataRegs.GPBDAT.bit.GPIO61
// Configure the start/end period for the timer
#define   DIR_L  GpioDataRegs.GPBDAT.bit.GPIO49
#define   DIR_R  GpioDataRegs.GPADAT.bit.GPIO25
// Prototype statements for functions found within this file.
interrupt void ecap1_isr(void);
interrupt void ecap5_isr(void);
void InitECapture1(void);
void InitECapture5(void);
void InitLed(void);
void InitDIR(void);
// Global variables used in this example
Uint32  ECap1IntCount;
Uint32  ECap5IntCount;
Uint32  Period1 = 0;
Uint32  Period5 = 0;
Uint32  Time1[24]={0};
Uint32  Time5[24]={0};
Uint32  T_Per_L = 0;
Uint32  T_Per_R = 0;
Uint32  Turn_R = 0;
Uint32  Turn_L = 0;
float  Spd_L = 0;
float  Spd_R = 0;
// To keep track of which way the timer value is moving
void main(void)
{

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2833x_SysCtrl.c file.
   InitSysCtrl();
   InitLed();
   InitDIR();
// Step 2. Initalize GPIO:
// This example function is found in the DSP2833x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();  // Skipped for this example  
   
   InitECap1Gpio();
   InitECap5Gpio();
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
   DINT;

// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.  
// This function is found in the DSP2833x_PieCtrl.c file.
   InitPieCtrl();
   
// Disable CPU interrupts and clear all CPU interrupt flags:
   IER = 0x0000;
   IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).  
// This will populate the entire table, even if the interrupt
// is not used in this example.  This is useful for debug purposes.
// The shell ISR routines are found in DSP2833x_DefaultIsr.c.
// This function is found in DSP2833x_PieVect.c.
   InitPieVectTable();

// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.  
   EALLOW;  // This is needed to write to EALLOW protected registers
   PieVectTable.ECAP1_INT = &ecap1_isr;
   PieVectTable.ECAP5_INT = &ecap5_isr;
   EDIS;    // This is needed to disable write to EALLOW protected registers

// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2833x_InitPeripherals.c
// InitPeripherals();  // Not required for this example

   InitECapture1();
   InitECapture5();
   
// Step 5. User specific code, enable interrupts:

// Initalize counters:   
    ECap1IntCount = 0;
    ECap5IntCount = 0;
   
// Enable CPU INT4 which is connected to ECAP1-4  INT:
   IER |= M_INT4;

// Enable eCAP INTn in the PIE: Group 4 interrupt 1-6
   PieCtrlRegs.PIEIER4.bit.INTx1 = 1;
   PieCtrlRegs.PIEIER4.bit.INTx5 = 1;
// Enable global Interrupts and higher priority real-time debug events:
   EINT;   // Enable Global interrupt INTM
   ERTM;   // Enable Global realtime interrupt DBGM

// Step 6. IDLE loop. Just sit and loop forever (optional):
   for(;;)
   {
      asm("NOP");
   }

}

void InitECapture1()
{
   ECap1Regs.ECEINT.all = 0x0000;             // Disable all capture interrupts 禁用所有中断使能寄存器
   ECap1Regs.ECCLR.all = 0xFFFF;              // Clear all CAP interrupt flags 清除所有CAP中断旗帜
   ECap1Regs.ECCTL1.bit.CAPLDEN = 0;          // Disable CAP1-CAP4 register loads 禁止在捕获事件中加载CAP1-4寄存器的时间
   ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0;        // Make sure the counter is stopped 计数器停止
   
   // Configure peripheral registers
   ECap1Regs.ECCTL2.bit.CAP_APWM = 0;         // CAP moudle ECAP模块工作于捕捉模式
   ECap1Regs.ECCTL2.bit.CONT_ONESHT = 1;      // One shot 单次模式
   ECap1Regs.ECCTL2.bit.STOP_WRAP = 0;        // Stop at 1 events 单次模式下,在CAP1的捕捉事件发生后产生停止信号
   ECap1Regs.ECCTL1.bit.CAP1POL = 0;          // Rising edge CAP1上升沿捕捉
   // ECap1Regs.ECCTL1.bit.CAP2POL = 0;        // Falling edge
   // ECap1Regs.ECCTL1.bit.CAP3POL = 0;        // Rising edge
   //ECap1Regs.ECCTL1.bit.CAP4POL = 0;        // Falling edge
   ECap1Regs.ECCTL1.bit.CTRRST1 = 1;          // Difference operation  在CAP1捕获后重置计数器
   // ECap1Regs.ECCTL1.bit.CTRRST2 = 1;        // Difference operation
   //ECap1Regs.ECCTL1.bit.CTRRST3 = 1;        // Difference operation
   //ECap1Regs.ECCTL1.bit.CTRRST4 = 1;        // Difference operation
   ECap1Regs.ECCTL2.bit.SYNCI_EN = 0;         // Disable sync 屏蔽同步输入操作
   ECap1Regs.ECCTL2.bit.SYNCO_SEL = 2;        // Disable sync out 屏蔽同步信号输出
   ECap1Regs.ECCTL1.bit.CAPLDEN = 1;          // Enable CAP1-CAP4 register loads 使能在捕获事件中加载CAP1-4寄存器的时间
   ECap1Regs.ECCTL1.bit.PRESCALE = 0;         //输入信号不分频

   ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1;        // Start Counter 计数器计数
   ECap1Regs.ECCTL2.bit.REARM = 1;            // arm one-shot 以下情况将强制为单次模式
   ECap1Regs.ECEINT.bit.CEVT1 = 1;            // CEVENT = interrupt 捕获事件1中断使能
}

void InitECapture5()
{
   ECap5Regs.ECEINT.all = 0x0000;             // Disable all capture interrupts   禁用所有中断使能寄存器
   ECap5Regs.ECCLR.all = 0xFFFF;              // Clear all CAP interrupt flags    清除所有CAP中断旗帜
   ECap5Regs.ECCTL1.bit.CAPLDEN = 0;          // Disable CAP1-CAP4 register loads 禁止在捕获事件中加载CAP1-4寄存器的时间
   ECap5Regs.ECCTL2.bit.TSCTRSTOP = 0;        // Make sure the counter is stopped 计数器停止
   
   // Configure peripheral registers
   ECap5Regs.ECCTL2.bit.CAP_APWM = 0;         // CAP moudle        ECAP模块工作于捕捉模式
   ECap5Regs.ECCTL2.bit.CONT_ONESHT = 1;      // One shot          单次模式
   ECap5Regs.ECCTL2.bit.STOP_WRAP = 0;        // Stop at 1 events  单次模式下,在CAP1的捕捉事件发生后产生停止信号
   ECap5Regs.ECCTL1.bit.CAP1POL = 0;          // Rising edge       CAP1上升沿捕捉
   //ECap5Regs.ECCTL1.bit.CAP2POL = 1;          // Falling edge
  // ECap5Regs.ECCTL1.bit.CAP3POL = 0;          // Rising edge
   //ECap5Regs.ECCTL1.bit.CAP4POL = 0;          // Falling edge
   ECap5Regs.ECCTL1.bit.CTRRST1 = 1;          // Difference operation      在CAP1捕获后重置计数器
   //ECap5Regs.ECCTL1.bit.CTRRST2 = 1;          // Difference operation         
   //ECap5Regs.ECCTL1.bit.CTRRST3 = 1;          // Difference operation         
   //ECap5Regs.ECCTL1.bit.CTRRST4 = 1;          // Difference operation         
   ECap5Regs.ECCTL2.bit.SYNCI_EN = 0;         // Disable sync              屏蔽同步输入操作
   ECap5Regs.ECCTL2.bit.SYNCO_SEL = 2;        // Disable sync out          屏蔽同步信号输出
   ECap5Regs.ECCTL1.bit.CAPLDEN = 1;          // Enable CAP1-CAP4 register loads  使能在捕获事件中加载CAP1-4寄存器的时间
   ECap5Regs.ECCTL1.bit.PRESCALE = 0;            //不分频

   ECap5Regs.ECCTL2.bit.TSCTRSTOP = 1;        // Start Counter  计数器计数
   ECap5Regs.ECCTL2.bit.REARM = 1;            // arm one-shot   以下情况将强制为单次模式
   ECap5Regs.ECEINT.bit.CEVT1 = 1;            //捕获事件4-1中断使能,1:使能
   //ECap6Regs.ECEINT.bit.CEVT2 = 1;            // CEVENT = interrupt  
}

interrupt void ecap1_isr(void)
{
   Uint32 i;
   LED1=~LED1;
   ECap1IntCount++;
   Period1 = ECap1Regs.CAP1;
   if (ECap1IntCount<=24)
   {
       Time1[ECap1IntCount-1] = Period1;
       Period1 = 0;
       if(ECap1IntCount==24)
       {
         for(i=0;i<24;i++)
         {
              T_Per_R = T_Per_R + Time1;
         }
         Spd_R = 2*PI*Radius/(float)T_Per_R/6.67*1000000000*60;
         T_Per_R = 0;
       }
   }
   else
   {
       Turn_R = Turn_R + 1;
       ECap1IntCount = 0;
   }
   
   ECap1Regs.ECCLR.bit.CEVT1 = 1;            //捕捉事件4~1标志,清除该位标志位
   ECap1Regs.ECCLR.bit.INT = 1;              //全局中断标志,清除该位标志位,不影响中断的使能
   ECap1Regs.ECCTL2.bit.REARM = 1;           //以下情况下将强制为单次模式:复位Mod4计数器为0,允许Mod4计数器持续计数,使能捕捉寄存器加载

   // Acknowledge this interrupt to receive more interrupts from group 4
   PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}

interrupt void ecap5_isr(void)
{
   Uint32 j;
   LED2=~LED2;
   ECap5IntCount++;
   Period5 = ECap5Regs.CAP1;
   if (ECap5IntCount<=24)
   {
       Time5[ECap5IntCount-1] = Period5;
       Period5 = 0;
       if(ECap5IntCount==24)
       {
         for(j=0;j<24;j++)
         {
              T_Per_L = T_Per_L + Time5[j];
         }
         Spd_L = 2*PI*Radius/(float)T_Per_L/6.67*1000000000*60;
         T_Per_L = 0;
       }
   }
   else
   {
       Turn_L = Turn_L + 1;
       ECap5IntCount = 0;
   }
   
   ECap5Regs.ECCLR.bit.CEVT1 = 1;              //捕捉事件4~1标志,清除该位标志位
   //ECap5Regs.ECCLR.bit.CEVT2 = 1;            // CEVENT = interrupt
   ECap5Regs.ECCLR.bit.INT = 1;                //全局中断标志,清除该位标志位,不影响中断的使能
   ECap5Regs.ECCTL2.bit.REARM = 1;             //以下情况下将强制为单次模式:复位Mod4计数器为0,允许Mod4计数器持续计数,使能捕捉寄存器加载
   // Acknowledge this interrupt to receive more interrupts from group 4
   PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;

}

void InitLed(void)
{
   EALLOW;
   GpioCtrlRegs.GPBMUX2.bit.GPIO60 = 0; // GPIO60 = GPIO60
   GpioCtrlRegs.GPBDIR.bit.GPIO60 = 1;  //Output
   LED1=1;
   GpioCtrlRegs.GPBMUX2.bit.GPIO61 = 0; // GPIO61 = GPIO61
   GpioCtrlRegs.GPBDIR.bit.GPIO61 = 1;  
   LED2=1;
   EDIS;
}
void InitDIR(void)
{
   EALLOW;
   GpioCtrlRegs.GPAMUX2.bit.GPIO25 = 0; // GPIO25 = GPIO25
   GpioCtrlRegs.GPADIR.bit.GPIO25 = 0;  // Intput
   GpioCtrlRegs.GPBMUX2.bit.GPIO49 = 0; // GPIO49 = GPIO49
   GpioCtrlRegs.GPBDIR.bit.GPIO49 = 0;  
   EDIS;
}
//===========================================================================
// No more.
//===========================================================================
请问捕获脉冲是从什么地方进入的?


使用特权

评论回复

相关帖子

沙发
zhangmangui| | 2019-8-5 23:29 | 只看该作者
配置合理的话    管脚上有对应配置的触发沿  就会触发进入ISR中断服务函数中

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

24

主题

33

帖子

0

粉丝