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

📄 aci34.c

📁 我刚开始学习变编程 ,不是很好,还请各位大侠多多帮助啊
💻 C
📖 第 1 页 / 共 4 页
字号:
    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==LEVEL4*/


#if (BUILDLEVEL==LEVEL5)
/*---------------------------------------------------------------------------*/
#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==LEVEL5*/


#if (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              
    
/*------------------------------------------------------------------------------
    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==LEVEL6*/

/* Change synchronous speed from pu value to rpm value (Q15 -> Q0)  */
/* Here the base speed is 3600 rpm  */
	 	dfoc.freq_testing_rpm = mul_q(dfoc.freq_testing,15,3600,0,0);

/* Change reference speed from pu value to rpm value (Q15 -> Q0)   */
/* Here the base speed is 3600 rpm  */
       	dfoc.speed_ref_rpm = mul_q(dfoc.speed_ref,15,3600,0,0);


  	asm("    SETC     XF ");   

}    /* c_int02() */            


void RstSystem(void)
{ 
/*-----------------------------------------------------------------------------
    First execute the initialization for the Wait Stage Genrator, 
    Global interrupt disable, Shut off the Watchdog, 
    and set up the Interupt Mask Register
-----------------------------------------------------------------------------*/
        WSGR=WAIT_STATES;         /* Initialize Wait State Generator         */
        disable_ints();           /* Make sure the interrupts are disabled   */
        wdog.disable();           /* Vccp/Wddis pin/bit must be high         */
        IMR=0x02;                 /* Set up interrupt mask to enable INT2    
                                     until an explicit enable.               */

/*-----------------------------------------------------------------------------
    Next we do the code for setting up the SCSR register, which is dependent 
    on the exact device the code is being compiled for (F243 / F2407).
-----------------------------------------------------------------------------*/
#if (TARGET==F243)
        SCSR=0x40c0;              /* Init SCSR */
        EVIMRA=0x0200;            /* Enable the timer underflow interrupt    */
#endif


#if (TARGET==F2407)
        SCSR1=0xc;                /* Init SCSR for 7.5 MHz cystal */
      /*  SCSR1=0x20c; */              /* Init SCSR for 15 MHz cystal */

        EVAIMRA=0x0200;           /* Enable the timer underflow interrupt    */
#endif

}   /* RstSystem(void) */
                          

void interrupt phantom(void)
{   

	static int phantom_count;
	phantom_count ++;
	
/*  Empty function: Used to handle any unwanted interrupts or events.
    All unused interrupt vectors are pointed to this function so that
    if any un-handled interrupts do get enabled, they are handled in a 
    benign manner, preventing un-intended branches, calls or execution
    into garbage.  
    Note that this function is an ISR, not a ordinary function.
*/
} /* phantom() */


/*------------------------------------------------------------------------------
    This function just provides a c-interface to the asm RTMON init function.
------------------------------------------------------------------------------*/
void rtmon_init(void)
{
    asm("       CALL    MON_RT_CNFG ");
}  /* rtmon_init() */




     






⌨️ 快捷键说明

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