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.

TMS320F2800157-Q1: AGPIO initial problem

Part Number: TMS320F2800157-Q1


void main(void)
{
    memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
    InitFlash();
    //
    // Initialize device clock and peripherals
    //
    InitSysCtrl();
    //
    // Initialize GPIO and configure the GPIO pin as a push-pull output
    InitGpio();
    EALLOW;
    GpioCtrlRegs.GPHAMSEL.bit.GPIO230=0;
    GpioCtrlRegs.GPHGMUX1.bit.GPIO230=0;
    GpioCtrlRegs.GPHMUX1.bit.GPIO230=0;
    GpioCtrlRegs.GPHDIR.bit.GPIO230=0;
    GpioCtrlRegs.GPHPUD.bit.GPIO230=0;
 //   AnalogSubsysRegs.AGPIOCTRLH.bit.GPIO230=0;

 //   GpioCtrlRegs.GPHLOCK.bit.GPIO230=1;
    //
    GpioCtrlRegs.GPHAMSEL.bit.GPIO227=0;
    GpioCtrlRegs.GPHGMUX1.bit.GPIO227=0;
    GpioCtrlRegs.GPHMUX1.bit.GPIO227=0;
    GpioCtrlRegs.GPHDIR.bit.GPIO227=0;
    GpioCtrlRegs.GPHPUD.bit.GPIO227=0;
 //   AnalogSubsysRegs.AGPIOCTRLH.bit.GPIO227=0;

 //   GpioCtrlRegs.GPHLOCK.bit.GPIO227=1;
    //
    GpioCtrlRegs.GPHAMSEL.bit.GPIO224=0;
    GpioCtrlRegs.GPHGMUX1.bit.GPIO224=0;
    GpioCtrlRegs.GPHMUX1.bit.GPIO224=0;
    GpioCtrlRegs.GPHDIR.bit.GPIO224=0;
    GpioCtrlRegs.GPHPUD.bit.GPIO224=0;
 //   AnalogSubsysRegs.AGPIOCTRLH.bit.GPIO224=0;

  //  GpioCtrlRegs.GPHLOCK.bit.GPIO224=1;
    EDIS;
    //
    InitEPwmGpio();
    //
    // Initialize PIE and clear PIE registers. Disables CPU interrupts. 
    //
    DINT;
    InitPieCtrl();
    IER = 0x0000;
    IFR = 0x0000;
    //
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    //
    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.EPWM1_INT = &MainISR;
    //PieVectTable.TINT0 = &cpu_timer0_isr;
    EDIS;    // This is needed to disable write to EALLOW protected registers
    //
    // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
    //
    InitEPWM();
    pwm_disable();
    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
    EDIS;
    //  Enable CPU INT3 which is connected to EPWM1-3 INT:
    IER |= M_INT3;
    // Enable EPWM INTn in the PIE: Group 3 interrupt 1-3
    PieCtrlRegs.PIEIER3.bit.INTx1 = 1;
    // Enable global Interrupts and higher priority real-time debug events:
    EINT;   // Enable Global interrupt INTM
    ERTM;   // Enable Global realtime interrupt DBGM
    //
    // Loop Forever
    //
    for(;;)
    {
        //
        // Delay for a bit.
        //
        DELAY_US(500000);
    }
}

When I initialize AGPIO pins 224, 227, and 230, especially when initializing the AMSEL register, PWM interrupts cannot enter, but the input status of the relevant pins can be identified. When I only block the AMSEL register and everything else remains unchanged, PWM interrupts can enter normally, but the input status on AGPIO cannot be read.

  • 您好,

    已经收到了您的案例,调查需要些时间,感谢您的耐心等待。

  • interrupt void MainISR(void)
    {
        EMF_U_STATUS=GpioDataRegs.GPHDAT.bit.GPIO230;
        EMF_V_STATUS=GpioDataRegs.GPHDAT.bit.GPIO227;
        EMF_W_STATUS=GpioDataRegs.GPHDAT.bit.GPIO224;
        //缓存io状态
        Queue_UStatus= Queue_UStatus << 1;//左移
        Queue_VStatus= Queue_VStatus << 1;
        Queue_WStatus= Queue_WStatus << 1;
    
        Queue_UStatus |= EMF_U_STATUS; //赋值
        Queue_VStatus |= EMF_V_STATUS;
        Queue_WStatus |= EMF_W_STATUS;
    
        //连续检测消除杂波
        status_h = Queue_UStatus & FilterNums;
        if(status_h == FilterNums) Filter_U_Status = 1;
        else if(status_h == 0x0) Filter_U_Status = 0;
        else return;
    
        status_h = Queue_VStatus & FilterNums;
        if(status_h == FilterNums) Filter_V_Status = 1;
        else if(status_h == 0x0) Filter_V_Status = 0;
        else return;
    
        status_h = Queue_WStatus & FilterNums;
        if(status_h == FilterNums) Filter_W_Status = 1;
        else if(status_h == 0x0) Filter_W_Status = 0;
        else return;
    您好,我已解决此问题。此问题的原因在于中断内部函数的处理,跟GPIO没有任何关系。可以看我中断内部的代码,里面的else return。当GPIO被初始化后,会执行到else return 这条语句。编译器直接认为是退出中断,所以体现出来的现象是中断进不去。其实中断一直在进,只不过被强制返回了而已。当GPIO没有正确初始化时,这部分语句应该是直接被编译器优化掉了,所以中断可以正常进行。