This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

F28027中断



程序中有ADC采样模块和pwm输出模块时,ADC正常运行,pwm只有中断不能响应,如果将ADC模块屏蔽,pwm中断又能响应。刚开始以为是ADC中断的问题,将ADC中断取消后,ADC无中断,功能正常,pwm中断依旧不能响应。请问这是为什么??求大神指教

  • 请问程序中ADC模块和PWM模块有什么关联吗?比如PWM触发ADC?或者ADC触发PWM?还是两者都是单独的触发源触发的?
  • 有关联,ADC模块的触发源就是pwm2A,触发事件是CTR = PRD, 计数方式是增减计数,
    PWM中断触发事件是CTR = 0,我监控pwm1中断发现只要有ADC模块存在,pwm1中断就不会响应,但是屏蔽ADC模块,pwm1中断又能响应。
    我曾经尝试将ADC模块触发源替换成CPUTimer0定时器中断触发,替换后采样没有问题,但是pwm中断依旧不会响应。
    所以我猜测可能是ADC模块对pwm中断有影响,请问会不会因为是这个地方配置有问题?
    void InitAdc(void)
    {
    extern void DSP28x_usDelay(Uint32 Count);

    // *IMPORTANT*
    // The Device_cal function, which copies the ADC calibration values from TI reserved
    // OTP into the ADCREFSEL and ADCOFFTRIM registers, occurs automatically in the
    // Boot ROM. If the boot ROM code is bypassed during the debug process, the
    // following function MUST be called for the ADC to function according
    // to specification. The clocks to the ADC MUST be enabled before calling this
    // function.
    // See the device data manual and/or the ADC Reference
    // Manual for more information.

    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;
    (*Device_cal)();
    EDIS;

    // To powerup the ADC the ADCENCLK bit should be set first to enable
    // clocks, followed by powering up the bandgap, reference circuitry, and ADC core.
    // Before the first conversion is performed a 5ms delay must be observed
    // after power up to give all analog circuits time to power up and settle

    // Please note that for the delay function below to operate correctly the
    // CPU_RATE define statement in the F2802x_Examples.h file must
    // contain the correct CPU clock period in nanoseconds.
    EALLOW;
    AdcRegs.ADCCTL1.bit.ADCBGPWD = 1; // Power ADC BG
    AdcRegs.ADCCTL1.bit.ADCREFPWD = 1; // Power reference
    AdcRegs.ADCCTL1.bit.ADCPWDN = 1; // Power ADC
    AdcRegs.ADCCTL1.bit.ADCENABLE = 1; // Enable ADC
    AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; // Select internal BG
    EDIS;

    DELAY_US(ADC_usDELAY); // Delay before converting ADC channels
    }
  • 我的pwm中断按照例程来的,会有可能是中断寄存器配置错误吗?
    void PWM_ISR()
    {
    EALLOW; // This is needed to write to EALLOW protected registers
    PieVectTable.EPWM1_INT = &epwm1_isr;
    PieVectTable.EPWM2_INT = &epwm2_isr;
    PieVectTable.EPWM3_INT = &epwm3_isr;
    EDIS; // This is needed to disable write to EALLOW protected registers
    PieCtrlRegs.PIEIER3.bit.INTx1 = 1;// Enable EPWM INTn in the PIE: Group 3 interrupt 1-3
    PieCtrlRegs.PIEIER3.bit.INTx2 = 1;
    PieCtrlRegs.PIEIER3.bit.INTx3 = 1;
    IER |= M_INT3;
    EINT;
    }

    EPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // ctr = 0时产生中断
    EPwm1Regs.ETSEL.bit.INTEN = 1; // 使能PWM中断
    EPwm1Regs.ETPS.bit.INTPRD = 1; // Generate INT on 3rd event