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.

[参考译文] TMS320F28035:定时器基座计数器失败?

Guru**** 1623435 points
Other Parts Discussed in Thread: DRV8837, CONTROLSUITE
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/998810/tms320f28035-timer-base-counter-fail

器件型号:TMS320F28035
Thread 中讨论的其他器件:DRV8837controlSUITE

您好!

我使用 epwm1来馈入 DRV8837 (基于2xDC 电机示例)。

我使用 ADC 来感测电机电流和3个其他信号。

在 epwm1上同步 ADC 以捕捉电机电流。

 

过去几个月都可以正常工作、但自从上次更新固件后、我出现了一种奇怪的行为...

我不认为我的改变是造成这种麻烦的真正原因、请参阅下文

初始代码:

        // Compute filtered value of initial guide sensor position
        for(j = SIGNAL_LENGTH; j > 0; j--)
        {
            iirHall.input = AdcResult.ADCRESULT1 << 3;                              // SOC1, IQ12 to 15
            iirHall.calc(&iirHall);
            DELAY_US(40);
        }

        // Compute filtered value of initial paddle value
        for(j = SIGNAL_LENGTH; j > 0; j--)
        {
            iirClick.input = (AdcResult.ADCRESULT3 - AdcResult.ADCRESULT2) << 3;    // SOC3 - SOC2, IQ12 to 15
            iirClick.calc(&iirClick);
            DELAY_US(40);
        }

更改:

        // Compute filtered value
        for(j = SIGNAL_LENGTH; j > 0; j--)
        {
            // Initial guide sensor position
            iirHall.input = AdcResult.ADCRESULT1 << 3;                              // SOC1, IQ12 to 15
            iirHall.calc(&iirHall);
            // Initial paddle value
            iirClick.input = (AdcResult.ADCRESULT3 - AdcResult.ADCRESULT2) << 3;    // SOC3 - SOC2, IQ12 to 15
            iirClick.calc(&iirClick);
            DELAY_US(40);
        }

在某些未知情况下、ADC 不会启动转换(在 AdcOffsetSelfCal 之后保持在偏移值80)或稍后启动。

TBCLKSYNC 被使能、但是当从复位开始时 TBCTR 并不总是在计数。

以下代码使问题变得更加频繁(如果从 DeviceInit()中启用了 TBCLKSYNC 并且不再更改,则不会出现此问题)

    // Self calibration on internal ref
    AdcInit();

    // Enable 5V
    // Note: external 3.3V ref needs 2ms settling time
    GpioDataRegs.GPASET.bit.GPIO10 = 1;
    DELAY_US(2000.0L);

    // Initialize PWM module
    pwm1.PeriodMax = PWM_PRD_MAX;

    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
    EDIS;

    PWM_INIT_MACRO(pwm1)

    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
    EDIS;

    // Initialize ADC module
    ADC_MACRO_INIT()

 

ADC 转换在 CCS 在调试模式下重新启动后运行良好、但在复位后均不运行。

在"释放"运行时、TMS320在启动前由 MSP430通过 XRS 保持在复位状态大约800ms。

如果 MSP430被复位、TMS320由 MSP430再次复位。

我想这种行为已经存在了一段时间、因为这种变化看起来微不足道、但现在 TMS320在复位后无法频繁启动转换。

有什么想法可以将定时器基座模块设置为有问题?

在设置 ADC 校准、ePWM1和 ADC SoC 时是否有其他建议?

如果在使用内部带隙进行自校准后对 ADC 使用外部基准、是否有任何建议?

配置:CCS9.3和 ti-CGT-C2000_18.12.7.LTS

谢谢你

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    [引用 userid="256302" URL"~/support/microcontrollers/c2000/f/c2000-microcontrollers-forum/998810/tms320f28035-timer-base-counter-fail ]ePWM1[/quot]

    /* ==================================================================================
    File name:        F2803xPWM.H
                        
    Originator:	 Digital Control Systems Group
    			 Texas Instruments
    			 C:\ti\controlSUITE\libs\app_libs\motor_control\drivers\f2803x_v2.1
    Description: Header file containing data type, object, macro definitions and 
    			 initializers. This file is specific to PM302.510 PCB and configure ePWM 1
    
    Target: TMS320F280x family
                  
    =====================================================================================
    History:
    -------------------------------------------------------------------------------------
     07-28-2010	Version 1.0
    ------------------------------------------------------------------------------------*/
    
    #ifndef __F280X_PWM_H__
    #define __F280X_PWM_H__
    
    //#include "f2803xbmsk.h"
    
    /*----------------------------------------------------------------------------
    Initialization constant for the F280X Time-Base Control Registers for PWM Generation. 
    Sets up the timer to run free upon emulation suspend, count up-down mode
    prescaler 1.
    ----------------------------------------------------------------------------*/
    #define PWM_INIT_STATE ( FREE_RUN_FLAG +         \
                             PRDLD_IMMEDIATE  +       \
                             TIMER_CNT_UPDN +         \
                             HSPCLKDIV_PRESCALE_X_1 + \
                             CLKDIV_PRESCALE_X_1  +   \
                             PHSDIR_CNT_UP    +       \
                             CNTLD_DISABLE )
    
    /*----------------------------------------------------------------------------
    Initialization constant for the F280X Compare Control Register. 
    ----------------------------------------------------------------------------*/
    #define CMPCTL_INIT_STATE ( LOADAMODE_ZRO + \
                                LOADBMODE_ZRO + \
                                SHDWAMODE_SHADOW + \
                                SHDWBMODE_SHADOW )
    
    /*----------------------------------------------------------------------------
    Initialization constant for the F280X Action Qualifier Software Force Register. 
    ----------------------------------------------------------------------------*/
    #define AQSFRC_INIT_STATE	( RLDCSF_PRD )
    //#define AQSFRC_INIT_STATE	( RLDCSF_PRD + ACTSFA_CLEAR + ACTSFB_CLEAR + 0x04 + 0x20)
    
    /*----------------------------------------------------------------------------
    Initialization constant for the F280X Action Qualifier Output A Register. 
    ----------------------------------------------------------------------------*/
    #define AQCTLA_INIT_STATE	( CAU_SET + CAD_CLEAR )
    #define AQCTLB_INIT_STATE	( CAU_SET + CAD_CLEAR )
    
    /*----------------------------------------------------------------------------
    Initialization constant for the F280X Dead-Band Generator registers for PWM Generation. 
    Sets up the dead band for PWM and sets up dead band values.
    ----------------------------------------------------------------------------*/
    #define DBCTL_INIT_STATE	(BP_DISABLE)
    
    /*----------------------------------------------------------------------------
    Initialization constant for the F280X PWM Chopper Control register for PWM Generation. 
    ----------------------------------------------------------------------------*/
    #define  PCCTL_INIT_STATE	(CHPEN_DISABLE)
    
    /*----------------------------------------------------------------------------
    Initialization constant for the F280X Trip Zone Select Register 
    ----------------------------------------------------------------------------*/
    #define  TZSEL_INIT_STATE	(DISABLE_TZSEL)
    							            
    /*----------------------------------------------------------------------------
    Initialization constant for the F280X Trip Zone Control Register 
    ----------------------------------------------------------------------------*/
    //#define  TZCTL_INIT_STATE ( TZA_FORCE_LO + TZB_FORCE_LO + \
                                DCAEVT1_HI_Z + DCAEVT2_HI_Z + \
                                DCBEVT1_HI_Z + DCBEVT2_HI_Z )
                                                                     
    /*-----------------------------------------------------------------------------
    	Define the structure of the PWM Driver Object 
    -----------------------------------------------------------------------------*/
    typedef struct {   
            Uint16 PeriodMax;     // Parameter: PWM Half-Period in CPU clock cycles (Q0)
            int16 MfuncPeriod;    // Input: Period scaler (Q15) 
            int16 MfuncC1;        // Input: EPWM1 A&B Duty cycle ratio (Q15)
    		int16 PWM1out;
            } PWMGEN ;    
    
    /*-----------------------------------------------------------------------------
    	Define a PWMGEN_handle
    -----------------------------------------------------------------------------*/
    typedef PWMGEN *PWMGEN_handle;
    
    /*------------------------------------------------------------------------------
    	Default Initializers for the F280X PWMGEN Object 
    ------------------------------------------------------------------------------*/
    #define F280X_FC_PWM_GEN    { 1000,   \
                                  0x7FFF, \
                                  0x4000, \
    							  0x4000, \
                                 }
                                  
    
    #define PWMGEN_DEFAULTS 	F280X_FC_PWM_GEN
    
    /*------------------------------------------------------------------------------
    	PWM Init & PWM Update Macro Definitions
    ------------------------------------------------------------------------------*/
    #define PWM_INIT_MACRO(v)													\
    	     /* Setup Sync */													\
             EPwm1Regs.TBCTL.bit.SYNCOSEL = 0;       /* Pass through */			\
            																	\
             /* Allow each timer to be sync'ed */								\
             EPwm1Regs.TBCTL.bit.PHSEN = 1;										\
    																			\
             /* Init Timer-Base Period Register for EPWM1 */					\
             EPwm1Regs.TBPRD = v.PeriodMax;										\
    																			\
             /* Init Compare Register for EPWM1 */								\
             EPwm1Regs.CMPA.half.CMPA = v.PeriodMax;							\
    																			\
             /* Init Timer-Base Phase Register for EPWM1 */						\
             EPwm1Regs.TBPHS.half.TBPHS = 0;									\
    																			\
             /* Init Timer-Base Control Register for EPWM1 */					\
             EPwm1Regs.TBCTL.all = PWM_INIT_STATE;								\
    																			\
             /* Init Compare Control Register for EPWM1 */						\
             EPwm1Regs.CMPCTL.all = CMPCTL_INIT_STATE;							\
    																			\
             /* Init Action Qualifier Output A Register for EPWM1 */			\
             EPwm1Regs.AQCTLA.all = AQCTLA_INIT_STATE;							\
    																			\
             /* Init Action Qualifier Output B Register for EPWM1 */			\
             EPwm1Regs.AQCTLB.all = AQCTLB_INIT_STATE;							\
    																			\
             /* Init Action Qualifier S/W Force Register for EPWM1 */			\
             EPwm1Regs.AQSFRC.all = AQSFRC_INIT_STATE;							\
    																			\
             /* Init Dead-Band Generator Control Register for EPWM1 */			\
             EPwm1Regs.DBCTL.all = DBCTL_INIT_STATE;							\
    																			\
             /* Init PWM Chopper Control Register for EPWM1 */					\
             EPwm1Regs.PCCTL.all = PCCTL_INIT_STATE;							\
    																			\
             EALLOW;                       /* Enable EALLOW */					\
             /* Init Trip Zone Select Register */								\
             EPwm1Regs.TZSEL.all = TZSEL_INIT_STATE;							\
             /* Init Trip Zone Control Register */								\
             /*EPwm1Regs.TZCTL.all = TZCTL_INIT_STATE;	*/						\
             EDIS;                         /* Disable EALLOW */

    [引用 userid="256302" URL"~/support/microcontrollers/c2000/f/c2000-microcontrollers-forum/998810/tms320f28035-timer-base-counter-fail ]ADC SoC[/引用]

    /* ==================================================================================
    File name:       F2803XADC.H
                        
    Originator:	Digital Control Systems Group
    			Texas Instruments
    			C:\ti\controlSUITE\libs\app_libs\motor_control\drivers\f2803x_v2.1
    
    Description: This header file contains macro definition for ADC initialization within PM 302
    
    Target: TMS320F2803x family
                  
    =====================================================================================
    History:
    -------------------------------------------------------------------------------------
     07-28-2010	Version 1.0 
    -----------------------------------------------------------------------------------*/
    
    #ifndef __F2803XADC_H__
    #define __F2803XADC_H__
    
    //#include "f2803xbmsk.h"
    
    /*-----------------------------------------------------------------------------------
     ADC Initialization Macro Definition 
    -----------------------------------------------------------------------------------*/
    #define ADC_usDELAY         1000L   // according to "SPRUI10 Technical Reference Manual"
    
    extern void DSP28x_usDelay(unsigned long Count);
    
    /*-----------------------------------------------------------------------------------
     Errata:
     - Avoid using ACQPS = 6 or 7
    
     Calibration:
     - Offset trim registers are erased upon an ADC master reset
         -> Do not perform ADC master reset else Device_cal() will be needed again
    
     ADC Power Modes:
    
        Mode A (operating)   Mode B (quick wake-up)  Mode C (Comparator)    Mode D (Off)
        13mA                  4mA                     1.5mA                 0.075mA
    
        BG ON                 BG ON                   BG ON                 BG OFF
        REF ON                REF ON                  REF OFF               REF OFF
        ADC ON                ADC OFF                 ADC OFF               ADC OFF
    -----------------------------------------------------------------------------------*/
    
    #define ADC_MACRO_INIT()																		\
    																								\
    	/*DELAY_US(ADC_usDELAY);*/																	\
    	/*AdcRegs.ADCCTL1.bit.RESET       = 1;	    Needs 2 cycles */						        \
    	/*asm(" NOP ");*/																			\
    	/*asm(" NOP ");*/    																		\
    																								\
    	EALLOW;																						\
    	                                                                                            \
    	AdcRegs.ADCCTL1.bit.ADCREFSEL	= 1;	/* External ref */									\
       	AdcRegs.ADCCTL1.bit.ADCREFPWD	= 1;	/* Power up reference */							\
       	AdcRegs.ADCCTL1.bit.ADCBGPWD    = 1;    /* Power up band gap */                             \
       	AdcRegs.ADCCTL1.bit.ADCPWDN 	= 1;	/* Power up rest of ADC */							\
    	AdcRegs.ADCCTL1.bit.ADCENABLE	= 1;	/* Enable ADC */									\
    	                                                                                            \
    	DELAY_US(ADC_usDELAY);                  /* Delay before performing the first conversion */  \
    																								\
    	asm(" RPT#100 || NOP");					/* useful ? */  									\
    																								\
    	AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1;	/* Interrupt pulse 1 cycle prior latching result */	\
    	AdcRegs.ADCCTL1.bit.TEMPCONV 	= 0;	/* No temperature conversion (A5) */				\
    	AdcRegs.ADCCTL2.bit.ADCNONOVERLAP = 1;  /* Overlap of sample is not allowed */              \
    																								\
    	/*DELAY_US(ADC_usDELAY);                    not useful... */            					\
    																								\
    	/******* CHANNEL SELECT *******/		                                                    \
    	/* Errata: Avoid using ACQPS value 6 and 7 */												\
    	AdcRegs.ADCSOC0CTL.bit.CHSEL 	= 1;   	/* ChSelect: ADC A1-> Motor current */ 			    \
    	AdcRegs.ADCSOC0CTL.bit.TRIGSEL 	= 5;	/* Set SOC0 start trigger on EPWM1A */				\
    	AdcRegs.ADCSOC0CTL.bit.ACQPS 	= 63;	/* Set SOC0 S/H Window to 64 ADC Clock Cycles, (63 ACQPS plus 1) */	\
    																								\
    	AdcRegs.ADCSOC1CTL.bit.CHSEL 	= 2;	/* ChSelect: ADC A2-> VHall Out */					\
    	AdcRegs.ADCSOC1CTL.bit.TRIGSEL  = 5;	/* Set SOC1 start trigger on software? */			\
    	AdcRegs.ADCSOC1CTL.bit.ACQPS 	= 63;	/* Conversion time 1283ns */	                    \
    																								\
    	AdcRegs.ADCSOC2CTL.bit.CHSEL    = 6;    /* ChSelect: ADC A6-> Click Down */ 				\
    	AdcRegs.ADCSOC2CTL.bit.TRIGSEL  = 5;	/* Set SOC2 start trigger on software? */			\
    	AdcRegs.ADCSOC2CTL.bit.ACQPS 	= 63;	/* Conversion time 1283ns */						\
    																								\
    	AdcRegs.ADCSOC3CTL.bit.CHSEL 	= 4;    /* ChSelect: ADC A4-> Click Up */					\
    	AdcRegs.ADCSOC3CTL.bit.TRIGSEL 	= 5;	/* Set SOC3 start trigger on software? */			\
    	AdcRegs.ADCSOC3CTL.bit.ACQPS 	= 63;	/* Conversion time 1283ns */						\
    	           																					\
    	EDIS;																						\
    																								\
    																								\
        /* Set up Event Trigger with CNT_zero enable for Time-base of EPWM1 */						\
        EPwm1Regs.ETSEL.bit.SOCAEN = 1;     /* Enable SOCA */										\
        EPwm1Regs.ETSEL.bit.SOCASEL = 1;    /* Enable CNT_zero event for SOCA */					\
        EPwm1Regs.ETPS.bit.SOCAPRD = 1;     /* Generate SOCA on the 1st event */					\
    	EPwm1Regs.ETCLR.bit.SOCA = 1;       /* Clear SOCA flag */									\
    																								\
    
    #endif // __F2803XADC_H__

    TMS 在 INTOSC1上以40MHz 运行(等待 PLL 锁定)。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您基于哪个示例项目? 请仅显示示例代码上的更改、以帮助我们快速了解您的问题。

    [引用 userid="256302" URL"~/support/microcontrollers/c2000/f/c2000-microcontrollers-forum/998810/tms320f28035-timer-base-counter-fail ]在调试模式下 CCS 重新启动后、ADC 转换运行良好、但在复位后均不会运行。[/quot]

    您是否首先单击"reset"、然后在 CCS 中单击"resstart"?

    [引用 userid="256302" URL"~/support/microcontrollers/c2000/f/c2000-microcontrollers-forum/998810/tms320f28035-timer-base-counter-fail "]关于什么可能会使计时器基模块发生故障的任何想法?[/quot]

    您可以检查 PWM 寄存器是否设置正确、并且 ePWM 模块的时钟是否启用。

    [引用 userid="256302" URL"~/support/microcontrollers/c2000/f/c2000-microcontrollers-forum/998810/tms320f28035-timer-base-counter-fail "]如果在使用内部带隙进行自校准后使用 ADC 的外部基准,是否有任何建议?[/quot]

    您可以参阅 controlSUITE 中的示例、如下所示。 只需更改 ADC 控制寄存器即可使用外部基准。

    C:\ti\controlSUITE\device_support\f2803x\v130\DSP2803x_examples_ccsv5\ADC_SoC

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    问题似乎已解决... 我知道什么代码段、但不知道确切的原因。

    我所做的更改是将 GPIO 设置从 DeviceInit()中移出,并将其放在 AdcInit()之后。 该 GPIO 变为高电平以启用5V 降压/升压、从而为电机、编码器和 Opas 供电。 OPA 在 TMS320的 ADCIN 上进行路由、以读取某些传感器、其中一个传感器在 TMS320启动前提供非零信号(情况仍然如此)。

    void main(void)
    {
        DeviceInit();   // Device Life support & GPIO
        InitSciGpio();  // SCI specific GPIO option
    
        // Self calibration on internal ref
        AdcInit();
    
        // Initialize PWM module
        // Note: disable and re-enable TBCLKSYNC to set PWM decrease liability (whatever datasheet says...)
        pwm1.PeriodMax = PWM_PRD_MAX;
        PWM_INIT_MACRO(pwm1)
    
        // Enable 5V
        // Note: external 3.3V ref needs 2ms settling time
        GpioDataRegs.GPASET.bit.GPIO10 = 1;
        DELAY_US(2000.0L);
    
        // Initialize ADC module
        ADC_MACRO_INIT()

    要回答您的问题:

    • 我单击了"Restart (重新启动)"或"Reset + Restart (重置+
    • PWM 时钟被启用并且配置良好

    我关于 ADC 基准设置的问题是、在改变 REF 源之前必须先将带隙、ADC 和 REF 断电。