⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aci34.c

📁 我刚开始学习变编程 ,不是很好,还请各位大侠多多帮助啊
💻 C
📖 第 1 页 / 共 4 页
字号:
        pwm.period_max=1333;       /* This is based on 15kHz PWM frequency (40MHz)*/
#endif  /* TARGET */            

/*-----------------------------------------------------------------------------
    Initialize the SDFOC_TI object. This is a call to the init method within 
    the SDFOC_TI object dfoc.
-----------------------------------------------------------------------------*/
        SDFOC_TI_Init(&dfoc);

/*-----------------------------------------------------------------------------
    Initialize the real time monitor
-----------------------------------------------------------------------------*/
        rtmon_init();            /* Call the monitor init function           */
        enable_ints();           /* Set off the system running.              */

/*-----------------------------------------------------------------------------
    Initialize DRIVE  --  Waiting for PWM enable flag setting 
-----------------------------------------------------------------------------*/
        while(drive.enable_flg==0)
        {
        drive.init(&drive);
        }

/*-----------------------------------------------------------------------------
    Initialize PWM Generator
-----------------------------------------------------------------------------*/
        pwm.init(&pwm);          

/*-----------------------------------------------------------------------------
    Initialize the capture interface
-----------------------------------------------------------------------------*/
        cap.init(&cap);

/*-----------------------------------------------------------------------------
    Initialize parameters of the speed calculation based on period
-----------------------------------------------------------------------------*/
        speed.shift = 6;  
        speed.speed_scaler = 156;
        speed.rpm_max = 3600;

/*-----------------------------------------------------------------------------
    Set the dac pointers
-----------------------------------------------------------------------------*/
        dac.qptr0=&ilg2_vdc.Imeas_a;
        dac.qptr1=&dfoc.fe.theta_r_fe;
        dac.qptr2=&dfoc.svgen.va;
        dac.qptr3=&dfoc.svgen.vb;

/*-----------------------------------------------------------------------------
    Initialize ILEG2VDCMEAS
-----------------------------------------------------------------------------*/
     	ilg2_vdc.init(&ilg2_vdc);

#endif /* (BUILDLEVEL==LEVEL6) */  


#if     TARGET==F243                      
        EVIFRA=0x0ffff;           /* Clear all Group A EV interrupt flags    */

#elif   TARGET==F2407                                                          
        EVAIFRA=0x0ffff;          /* Clear all EV1 Group A EV interrupt flags*/
#endif              


/*---------------------------------------------------------------------------*/
        while(1)             /* Nothing running in the background at present */
        { 
        
        }
/*---------------------------------------------------------------------------*/

} /* End: main() */

 
void interrupt c_int02()
{       
     asm("      CLRC     XF ");
     
     isr_ticker++;    

#if (BUILDLEVEL==LEVEL1)
/*---------------------------------------------------------------------------*/
#if     TARGET==F243                      
        EVIFRA=0x0ffff;           /* Clear all Group A EV interrupt flags    */

#elif   TARGET==F2407                                                          
        EVAIFRA=0x0ffff;          /* Clear all EV1 Group A EV interrupt flags*/
#endif              

/*------------------------------------------------------------------------------
    Call the enable/disable PWM signal drive function.
------------------------------------------------------------------------------*/
        drive.calc(&drive);

/*------------------------------------------------------------------------------
    Call the SDFOC_TI_Run function to perform the runtime tasks of the 
    SDFOC_TI algorithm.
------------------------------------------------------------------------------*/
        SDFOC_TI_Run(&dfoc); 

/*------------------------------------------------------------------------------
    Connect output of the DFOC.SVGEN to the PWM Driver and call the PWM driver 
    update function.
------------------------------------------------------------------------------*/
        pwm.mfunc_c1 = dfoc.svgen.va;         
        pwm.mfunc_c2 = dfoc.svgen.vb;
        pwm.mfunc_c3 = dfoc.svgen.vc;
        pwm.update(&pwm);

/*------------------------------------------------------------------------------
    Call the diagnostic DAC utility update function.
------------------------------------------------------------------------------*/
        dac.update(&dac);

/*----------------------------------------------------------------------------*/
#endif /* BUILDLEVEL==LEVEL1*/


#if (BUILDLEVEL==LEVEL2)
/*---------------------------------------------------------------------------*/
#if     TARGET==F243                      
        EVIFRA=0x0ffff;           /* Clear all Group A EV interrupt flags    */

#elif   TARGET==F2407                                                          
        EVAIFRA=0x0ffff;          /* Clear all EV1 Group A EV interrupt flags*/
#endif              

/*------------------------------------------------------------------------------
    Call the enable/disable PWM signal drive function.
------------------------------------------------------------------------------*/
        drive.calc(&drive);

/*------------------------------------------------------------------------------
    Call the SDFOC_TI_Run function to perform the runtime tasks of the 
    SDFOC_TI algorithm.
------------------------------------------------------------------------------*/
        SDFOC_TI_Run(&dfoc); 

/*------------------------------------------------------------------------------
    Connect output of the DFOC.SVGEN to the PWM Driver and call the PWM driver 
    update function.
------------------------------------------------------------------------------*/
        pwm.mfunc_c1 = dfoc.svgen.va;         
        pwm.mfunc_c2 = dfoc.svgen.vb;
        pwm.mfunc_c3 = dfoc.svgen.vc;
        pwm.update(&pwm);

/*------------------------------------------------------------------------------
    Call the ileg2_dcbus_drv function to perform the ADC tasks for 2 currents and 
    DC-bus measurement.     
------------------------------------------------------------------------------*/
        ilg2_vdc.read(&ilg2_vdc);

/*------------------------------------------------------------------------------
    Connect outputs of the ILEG2VDCMEAS to DFOC   
------------------------------------------------------------------------------*/
	  	dfoc.current_abc.a = ilg2_vdc.Imeas_a;
	  	dfoc.current_abc.b = ilg2_vdc.Imeas_b;
	  	dfoc.current_abc.c = ilg2_vdc.Imeas_c;        
        dfoc.Vbus = ilg2_vdc.Vdc_meas;

/*------------------------------------------------------------------------------
    Call the capture driver read function. Note, that this func returns the 
    status, as the return value, NOT the time_stamp. The time_stamp is returned
    directly into CAPTURE object structure.
------------------------------------------------------------------------------*/
        if((cap.read(&cap))==0)             /* Call the capture read function */
        {
        speed.time_stamp=cap.time_stamp;    /* Read out new time stamp        */
        speed.calc(&speed);                 /* Call the speed calulator       */
        dfoc.Mea_spd = speed.speed_prd;     /* Connect measured speed */
        }       

/*------------------------------------------------------------------------------
    Call the diagnostic DAC utility update function.
------------------------------------------------------------------------------*/
        dac.update(&dac);

/*----------------------------------------------------------------------------*/
#endif /* BUILDLEVEL==LEVEL2*/


#if (BUILDLEVEL==LEVEL3)
/*---------------------------------------------------------------------------*/
#if     TARGET==F243                      
        EVIFRA=0x0ffff;           /* Clear all Group A EV interrupt flags    */

#elif   TARGET==F2407                                                          
        EVAIFRA=0x0ffff;          /* Clear all EV1 Group A EV interrupt flags*/
#endif              

/*------------------------------------------------------------------------------
    Call the enable/disable PWM signal drive function.
------------------------------------------------------------------------------*/
        drive.calc(&drive);

/*------------------------------------------------------------------------------
    Call the SDFOC_TI_Run function to perform the runtime tasks of the 
    SDFOC_TI algorithm.
------------------------------------------------------------------------------*/
        SDFOC_TI_Run(&dfoc); 

/*------------------------------------------------------------------------------
    Connect output of the DFOC.SVGEN to the PWM Driver and call the PWM driver 
    update function.
------------------------------------------------------------------------------*/
        pwm.mfunc_c1 = dfoc.svgen.va;         
        pwm.mfunc_c2 = dfoc.svgen.vb;
        pwm.mfunc_c3 = dfoc.svgen.vc;
        pwm.update(&pwm);

/*------------------------------------------------------------------------------
    Call the ileg2_dcbus_drv function to perform the ADC tasks for 2 currents and 
    DC-bus measurement.     
------------------------------------------------------------------------------*/
        ilg2_vdc.read(&ilg2_vdc);

/*------------------------------------------------------------------------------
    Connect outputs of the ILEG2VDCMEAS to DFOC 
------------------------------------------------------------------------------*/
	  	dfoc.current_abc.a = ilg2_vdc.Imeas_a;
	  	dfoc.current_abc.b = ilg2_vdc.Imeas_b;
	  	dfoc.current_abc.c = ilg2_vdc.Imeas_c;        
        dfoc.Vbus = ilg2_vdc.Vdc_meas;

/*------------------------------------------------------------------------------
    Call the capture driver read function. Note, that this func returns the 
    status, as the return value, NOT the time_stamp. The time_stamp is returned
    directly into CAPTURE object structure.
------------------------------------------------------------------------------*/
        if((cap.read(&cap))==0)             /* Call the capture read function */
        {
        speed.time_stamp=cap.time_stamp;    /* Read out new time stamp        */
        speed.calc(&speed);                 /* Call the speed calulator       */
        dfoc.Mea_spd = speed.speed_prd;     /* Connect measured speed */
        }       

/*------------------------------------------------------------------------------
    Call the diagnostic DAC utility update function.
------------------------------------------------------------------------------*/
        dac.update(&dac);
      
/*----------------------------------------------------------------------------*/
#endif /* BUILDLEVEL==LEVEL3*/


#if (BUILDLEVEL==LEVEL4)
/*---------------------------------------------------------------------------*/
#if     TARGET==F243                      
        EVIFRA=0x0ffff;           /* Clear all Group A EV interrupt flags    */

#elif   TARGET==F2407                                                          
        EVAIFRA=0x0ffff;          /* Clear all EV1 Group A EV interrupt flags*/
#endif              

/*------------------------------------------------------------------------------
    Call the enable/disable PWM signal drive function.
------------------------------------------------------------------------------*/
        drive.calc(&drive);

/*------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -