📄 aci34.c
字号:
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
..\..\drv011\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 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.svgen.vb;
dac.qptr2=&dfoc.svgen.vc;
dac.qptr3=&dfoc.rg.rmp_out;
/*-----------------------------------------------------------------------------
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
..\..\drv011\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 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=&dfoc.rg.rmp_out;
dac.qptr1=&dfoc.svgen.va;
dac.qptr2=&dfoc.fe.theta_r_fe;
dac.qptr3=&dfoc.svgen.vb;
/*-----------------------------------------------------------------------------
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
..\..\drv011\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 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==LEVEL5) */
#if (BUILDLEVEL==LEVEL6)
/*-----------------------------------------------------------------------------
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
..\..\drv011\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) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -