📄 aci32.c
字号:
VFMRAS_TI_Init(&vhz);
/*-----------------------------------------------------------------------------
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);
/*-----------------------------------------------------------------------------
Set the dac pointers to the phases and alpha of the VHZ_TI object
phase outputs.
-----------------------------------------------------------------------------*/
dac.qptr0=&vhz.svgen.va;
dac.qptr1=&vhz.svgen.vb;
dac.qptr2=&vhz.svgen.vc;
dac.qptr3=&vhz.svgen.alpha;
/*-----------------------------------------------------------------------------
Initialize ILEG2VDCMEAS
-----------------------------------------------------------------------------*/
ilg2_vdc.init(&ilg2_vdc);
#endif /* (BUILDLEVEL==LEVEL3) */
#if (BUILDLEVEL==LEVEL4)
/*-----------------------------------------------------------------------------
Set the pwm period to 500 cycles,(F243) [ or 750 cycles, LF240x ].
This assumes a CPU CLKIN of 5MHz for the F243 and CLKIN of 7.5 MHz
for the LF240x.
Defaults for pwm are set in F243_PWM.H
Note that this will ONLY change runtime configurable parameters.
For changing settings like timer modes or PWM Polarity, once the
constants like PWM_INIT_STATE, or ACTR_INIT_STATE are changed, the
driver file must be re-compiled.
To do this change the constant and then run the batch file
..\..\drv010\build\f243drv.bat or f2407drv.bat
This will re-build the driver, with the new timer mode or PWM polarity,
and then run the (re)build for this project. This will update the
setting.
-----------------------------------------------------------------------------*/
#if TARGET==F243
pwm.period_max=667; /* This is based on 15kHz PWM frequency (20MHz) */
#elif TARGET==F2407
/* pwm.period_max=1000; */ /* This is based on 15kHz PWM frequency (30MHz) */
pwm.period_max=1333; /* This is based on 15kHz PWM frequency (40MHz)*/
#endif /* TARGET */
/*-----------------------------------------------------------------------------
Initialize the VFMRAS_TI object. This is a call to the init method within
the VFMRAS_TI object vhz.
-----------------------------------------------------------------------------*/
VFMRAS_TI_Init(&vhz);
/*-----------------------------------------------------------------------------
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 to the phases and alpha of the VHZ_TI object
phase outputs.
-----------------------------------------------------------------------------*/
dac.qptr0=&vhz.svgen.va;
dac.qptr1=&vhz.svgen.vb;
dac.qptr2=&vhz.svgen.vc;
dac.qptr3=&vhz.svgen.alpha;
/*-----------------------------------------------------------------------------
Initialize ILEG2VDCMEAS
-----------------------------------------------------------------------------*/
ilg2_vdc.init(&ilg2_vdc);
#endif /* (BUILDLEVEL==LEVEL4) */
#if (BUILDLEVEL==LEVEL5)
/*-----------------------------------------------------------------------------
Set the pwm period to 500 cycles,(F243) [ or 750 cycles, LF240x ].
This assumes a CPU CLKIN of 5MHz for the F243 and CLKIN of 7.5 MHz
for the LF240x.
Defaults for pwm are set in F243_PWM.H
Note that this will ONLY change runtime configurable parameters.
For changing settings like timer modes or PWM Polarity, once the
constants like PWM_INIT_STATE, or ACTR_INIT_STATE are changed, the
driver file must be re-compiled.
To do this change the constant and then run the batch file
..\..\drv010\build\f243drv.bat or f2407drv.bat
This will re-build the driver, with the new timer mode or PWM polarity,
and then run the (re)build for this project. This will update the
setting.
-----------------------------------------------------------------------------*/
#if TARGET==F243
pwm.period_max=667; /* This is based on 15kHz PWM frequency (20MHz) */
#elif TARGET==F2407
/* pwm.period_max=1000; */ /* This is based on 15kHz PWM frequency (30MHz) */
pwm.period_max=1333; /* This is based on 15kHz PWM frequency (40MHz)*/
#endif /* TARGET */
/*-----------------------------------------------------------------------------
Initialize the VFMRAS_TI object. This is a call to the init method within
the VFMRAS_TI object vhz.
-----------------------------------------------------------------------------*/
VFMRAS_TI_Init(&vhz);
/*-----------------------------------------------------------------------------
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 to the phases and alpha of the VHZ_TI object
phase outputs.
-----------------------------------------------------------------------------*/
dac.qptr0=&vhz.svgen.va;
dac.qptr1=&vhz.svgen.vb;
dac.qptr2=&vhz.svgen.vc;
dac.qptr3=&vhz.svgen.alpha;
/*-----------------------------------------------------------------------------
Initialize ILEG2VDCMEAS
-----------------------------------------------------------------------------*/
ilg2_vdc.init(&ilg2_vdc);
#endif /* (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
/*---------------------------------------------------------------------------*/
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 VFMRAS_TI_Run function to perform the runtime tasks of the
VFMRAS_TI algorithm.
------------------------------------------------------------------------------*/
VFMRAS_TI_Run(&vhz);
/*------------------------------------------------------------------------------
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 VFMRAS_TI_Run function to perform the runtime tasks of the
VFMRAS_TI algorithm.
------------------------------------------------------------------------------*/
VFMRAS_TI_Run(&vhz);
/*------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -