Part Number:TMS320F280021
Dear all
在做一个新项目使用的是280021芯片LQFP-48个管脚,GPIO已经不够用了,打算把AD 的输入端口配置为ECAP端口,
尝试把AIO224端口(A2)配置为ECAP输入端口,配置后,程序运行,发现ECAP中断无法进入。
ECAP 初始化程序如下:
InputXbarRegs.INPUT1SELECT = 224; //使用INPUT1–AIO224引脚
GpioCtrlRegs.GPHAMSEL.bit.GPIO224 = 1;//The analog function of the pin is disabled
GpioCtrlRegs.GPHQSEL1.bit.GPIO224 = 1; //GPIO配置为同步模式
GpioCtrlRegs.GPHCTRL.bit.QUALPRD0=150;
EALLOW;
ECap1Regs.ECCTL0.bit.INPUTSEL = 0; //ECap1捕获引脚对应到INTPUT0
ECap1Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap1Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap1Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped
// Configure peripheral registers
ECap1Regs.ECCTL2.bit.CAP_APWM = 0; // CAP mode
ECap1Regs.ECCTL2.bit.CONT_ONESHT = 0; // Continuous mode
ECap1Regs.ECCTL2.bit.STOP_WRAP = 1; // Stop at 2 events
ECap1Regs.ECCTL1.bit.PRESCALE = 0; // Divide by 1 分频
ECap1Regs.ECCTL1.bit.CAP1POL = 1; // falling edge
ECap1Regs.ECCTL1.bit.CAP2POL = 1; // falling edge
ECap1Regs.ECCTL1.bit.CTRRST1 = 1; // Difference operation
ECap1Regs.ECCTL1.bit.CTRRST2 = 0; // Difference operation
ECap1Regs.ECCTL2.bit.SYNCI_EN = 0; // Enable sync in
ECap1Regs.ECCTL2.bit.SYNCO_SEL = 3; // Disable sync out signal
ECap1Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter 启动
// ECap1Regs.ECEINT.bit.CEVT2 = 1; // 2 events = interrupt
ECap1Regs.ECEINT.bit.CEVT1 = 1; // 1 events = interrupt
EDIS;
帮忙看看是哪里配置不正确导致进不了ECAP中断,最主要就是AD输入口这边如何切换配置为ECAP捕获输入口。
Green Deng:
你好,试一下把GpioCtrlRegs.GPHAMSEL.bit.GPIO224 = 1;这个位设置为0之后再看看
,
Huit:
确实如此,修改过了就解决了,可以正常使用。
InputXbarRegs.INPUT1SELECT = 224; //使用INPUT1–AIO224引脚
GpioCtrlRegs.GPHAMSEL.bit.GPIO224 = 0;//The analog function of the pin is disabled GpioCtrlRegs.GPHQSEL1.bit.GPIO224 = 0; //GPIO配置为同步模式 GpioCtrlRegs.GPHCTRL.bit.QUALPRD0=150;