EVB时钟已经使能,网上有人回答是PDPINTA引脚问题,也是没搞懂。本人新手,求大神指导。或者有哪些硬件引脚会影响GPIOB引脚输出PWM波?
相关设置代码粘贴如下:
- void main(void)
- {
- /*初始化系统*/
- InitSysCtrl();
- /*关中断*/
- DINT;
- IER = 0x0000;
- IFR = 0x0000;
-
- /*初始化PIE控制寄存器*/
- InitPieCtrl();
-
- /*初始化PIE矢量表*/
- InitPieVectTable();
-
- /*初始化GPIO*/
- InitGpio();
-
- /*初始化EV*/
- InitEv();
- //EvaRegs.T1CON.bit.TENABLE = 1;
- //EvaRegs.T2CON.bit.TENABLE = 1;
- //EvbRegs.T3CON.bit.TENABLE = 1;
- //EvbRegs.T4CON.bit.TENABLE = 1;
-
- EINT;
- ERTM;
- for(;;)
- {
- KickDog();///剔除看门狗,防止对DSP进行复位
- }
- }
- void InitSysCtrl(void)
- {
- Uint16 i;
- EALLOW;
-
- // On TMX samples, to get the best performance of on chip RAM blocks M0/M1/L0/L1/H0 internal
- // control registers bit have to be enabled. The bits are in Device emulation registers.
- /* DevEmuRegs.M0RAMDFT = 0x0300;
- DevEmuRegs.M1RAMDFT = 0x0300;
- DevEmuRegs.L0RAMDFT = 0x0300;
- DevEmuRegs.L1RAMDFT = 0x0300;
- DevEmuRegs.H0RAMDFT = 0x0300;*/
-
-
- // Disable watchdog module
- SysCtrlRegs.WDCR= 0x0068;
- // Initalize PLL
- SysCtrlRegs.PLLCR = 0x03; ///系统时钟45M
- // Wait for PLL to lock
- for(i= 0; i< 5000; i++){}
-
- // HISPCP/LOSPCP prescale register settings, normally it will be set to default values
- SysCtrlRegs.HISPCP.all = 0x0001;///45M/2=22.5M
- SysCtrlRegs.LOSPCP.all = 0x0002;
- // Peripheral clock enables set for the selected peripherals.
- SysCtrlRegs.PCLKCR.bit.EVAENCLK=1;
- SysCtrlRegs.PCLKCR.bit.EVBENCLK=1;
- //SysCtrlRegs.PCLKCR.bit.SCIENCLKA=1;
- //SysCtrlRegs.PCLKCR.bit.SCIENCLKB=1;
-
- EDIS;
-
- }
- //---------------------------------------------------------------------------
- // KickDog:
- //---------------------------------------------------------------------------
- // This function resets the watchdog timer.
- // Enable this function for using KickDog in the application
- void KickDog(void)
- {
- EALLOW;
- SysCtrlRegs.WDKEY = 0x0055;
- SysCtrlRegs.WDKEY = 0x00AA;
- EDIS;
- }
- void InitGpio(void)
- {
- EALLOW;
- GpioMuxRegs.GPAMUX.all=0x00ff;
- GpioMuxRegs.GPBMUX.all=0x00ff;
- EDIS;
- }
- void InitEv(void)
- {
- EvaRegs.ACTR.all = 0x0666; ///通过对比较方式控制寄存器的配置,得PWM2低有效,PWM1高有效,改变设置可使电机反转
- EvaRegs.DBTCONA.all = 0x0000;///使能死区定时器,分频45/16=2.8125M,死区时间5*0.356us=1.78us
- EvaRegs.COMCONA.all = 0xa600; ///比较器控制A
- EvaRegs.T1PR =0xffff;
- EvaRegs.T1CMPR =0x3c00;
- EvaRegs.T1CNT = 0;
- EvaRegs.T1CON.all = 0x1042;
- EvaRegs.T2PR =0x0fff;
- EvaRegs.T2CMPR =0x03c0;
- EvaRegs.T2CNT = 0;
- EvaRegs.T2CON.all = 0x1042;
- EvaRegs.GPTCONA.bit.TCOMPOE = 1;
- EvaRegs.GPTCONA.bit.T1PIN = 1;
- EvaRegs.GPTCONA.bit.T2PIN = 2;
- EvaRegs.CMPR1 = 0x0C00;
- EvaRegs.CMPR2 = 0x3C00;
- EvaRegs.CMPR3 = 0xFC00;
- */
- EvbRegs.ACTRB.all = 0x0666; ///通过对比较方式控制寄存器的配置,得PWM2低有效,PWM1高有效,改变设置可使电机反转
- EvbRegs.DBTCONB.all = 0x0000;///使能死区定时器,分频45/16=2.8125M,死区时间5*0.356us=1.78us
- EvbRegs.COMCONB.all = 0xa600; ///比较器控制A
- EvbRegs.T3PR =0xFFFF; ////定时器1周期值0.356us*N
- EvbRegs.T3CMPR =0x3C00; ///定时器1比较值,没什么用,没用这种方式
- EvbRegs.T3CNT = 0; ///定时器1初值设为0
- EvbRegs.T3CON.all = 0x1042; ///连续增模式,TPS系数45M/2/16,T1使能,
- EvbRegs.T4PR =0x0fff; ////定时器1周期值0.356us*N
- EvbRegs.T4CMPR =0x03c0; ///定时器1比较值,没什么用,没用这种方式
- EvbRegs.T4CNT = 0; ///定时器1初值设为0
- EvbRegs.T4CON.all = 0x1042;
- EvbRegs.GPTCONB.bit.TCOMPOE = 1;
- EvbRegs.GPTCONB.bit.T3PIN = 1;
- EvbRegs.GPTCONB.bit.T4PIN = 2;
- //EvbRegs.EVBIMRA.bit.PDPINTB = 1;
- EvbRegs.CMPR4 = 0x0C00;
- EvbRegs.CMPR5 = 0x3C00;
- EvbRegs.CMPR6 = 0xFC00;
- }
复制代码
一周热门 更多>