|
@@ -23,6 +23,7 @@
|
|
|
/************************************************************************
|
|
|
Included File
|
|
|
*************************************************************************/
|
|
|
+#include "hwsetup.h"
|
|
|
#include "syspar.h"
|
|
|
#include "user.h"
|
|
|
#include "can.h"
|
|
@@ -1212,133 +1213,7 @@ void hw_voTimEn(void)
|
|
|
/* counter enable */
|
|
|
timer_enable(TIMER6);
|
|
|
}
|
|
|
-void hw_voPWMInit(void)
|
|
|
-{
|
|
|
- /* Set 50% duty */
|
|
|
- UWORD prd = iPwm_GetCountMax(0);
|
|
|
- iPwm_SetCompareValue(0, 0, prd >> 1);
|
|
|
- iPwm_SetCompareValue(0, 1, prd >> 1);
|
|
|
- iPwm_SetCompareValue(0, 2, prd >> 1);
|
|
|
- iPwm_SetCompareValueDelay(0, 0, prd >> 1);
|
|
|
- iPwm_SetCompareValueDelay(0, 1, prd >> 1);
|
|
|
- iPwm_SetCompareValueDelay(0, 2, prd >> 1);
|
|
|
-
|
|
|
- /* PWM off */
|
|
|
- hw_voPWMOff();
|
|
|
-
|
|
|
- /* Charge init */
|
|
|
- hw_uwChrgCt = 0;
|
|
|
- hw_blChrgOvrFlg = FALSE;
|
|
|
-}
|
|
|
-
|
|
|
-void hw_voPWMOn(void)
|
|
|
-{
|
|
|
-#if (0)
|
|
|
- timer_oc_parameter_struct timer_ocintpara;
|
|
|
-
|
|
|
- if (hw_blPWMOnFlg == FALSE)
|
|
|
- {
|
|
|
- /* CH0, CH1 and CH2 output enable */
|
|
|
- timer_ocintpara.outputstate = TIMER_CCX_ENABLE;
|
|
|
- timer_ocintpara.outputnstate = TIMER_CCXN_ENABLE;
|
|
|
- timer_channel_output_config(TIMER0, TIMER_CH_0, &timer_ocintpara);
|
|
|
- timer_channel_output_config(TIMER0, TIMER_CH_1, &timer_ocintpara);
|
|
|
- timer_channel_output_config(TIMER0, TIMER_CH_2, &timer_ocintpara);
|
|
|
-
|
|
|
- /* Flag set */
|
|
|
- hw_blPWMOnFlg = TRUE;
|
|
|
- }
|
|
|
-#endif
|
|
|
-
|
|
|
- if (hw_blPWMOnFlg == FALSE)
|
|
|
- {
|
|
|
- /* CH0, CH1 set to "PWM mode 2" */
|
|
|
- TIMER_CHCTL0(TIMER0) |= 0x7070;
|
|
|
- /* CH2, CH3 set to "PWM mode 2" */
|
|
|
- TIMER_CHCTL1(TIMER0) |= 0x7070;
|
|
|
- /* CH0, CH1 and CH2, CH3 output enable */
|
|
|
- TIMER_CHCTL2(TIMER0) |= 0x5555;
|
|
|
-
|
|
|
- /* Flag set */
|
|
|
- hw_blPWMOnFlg = TRUE;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void hw_voPWMOff(void)
|
|
|
-{
|
|
|
-#if (0)
|
|
|
- timer_oc_parameter_struct timer_ocintpara;
|
|
|
|
|
|
- if (hw_blPWMOnFlg == TRUE)
|
|
|
- {
|
|
|
- /* CH0, CH1 and CH2 output disable */
|
|
|
- timer_ocintpara.outputstate = TIMER_CCX_DISABLE;
|
|
|
- timer_ocintpara.outputnstate = TIMER_CCXN_DISABLE;
|
|
|
- timer_channel_output_config(TIMER0, TIMER_CH_0, &timer_ocintpara);
|
|
|
- timer_channel_output_config(TIMER0, TIMER_CH_1, &timer_ocintpara);
|
|
|
- timer_channel_output_config(TIMER0, TIMER_CH_2, &timer_ocintpara);
|
|
|
-
|
|
|
- /* Flag set */
|
|
|
- hw_blPWMOnFlg = FALSE;
|
|
|
- }
|
|
|
-#endif
|
|
|
-
|
|
|
- if (hw_blPWMOnFlg == TRUE)
|
|
|
- {
|
|
|
- /* CH0, CH1 set to "Frozen" */
|
|
|
- TIMER_CHCTL0(TIMER0) &= ~0x7070;
|
|
|
- /* CH2, CH3 set to "Frozen" */
|
|
|
- TIMER_CHCTL1(TIMER0) &= ~0x7070;
|
|
|
- /* CH0, CH1 set to "Force inactive level" */
|
|
|
- TIMER_CHCTL0(TIMER0) |= 0x4040;
|
|
|
- /* CH2, CH3 set to "Force inactive level" */
|
|
|
- TIMER_CHCTL1(TIMER0) |= 0x4040;
|
|
|
- /* CH0, CH1 and CH2 complementary output disable */
|
|
|
- TIMER_CHCTL2(TIMER0) &= ~0x0444;
|
|
|
-
|
|
|
- /* Flag set */
|
|
|
- hw_blPWMOnFlg = FALSE;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void hw_voCharge(void)
|
|
|
-{
|
|
|
- /* Set 50% duty */
|
|
|
- UWORD prd = iPwm_GetCountMax(0);
|
|
|
- iPwm_SetCompareValue(0, 0, prd >> 1);
|
|
|
- iPwm_SetCompareValue(0, 1, prd >> 1);
|
|
|
- iPwm_SetCompareValue(0, 2, prd >> 1);
|
|
|
- iPwm_SetCompareValueDelay(0, 0, prd >> 1);
|
|
|
- iPwm_SetCompareValueDelay(0, 1, prd >> 1);
|
|
|
- iPwm_SetCompareValueDelay(0, 2, prd >> 1);
|
|
|
-
|
|
|
- /* PWM on */
|
|
|
- hw_voPWMOn();
|
|
|
-
|
|
|
- ++hw_uwChrgCt;
|
|
|
- if (hw_uwChrgCt > cp_stControlPara.swIPMHvicChrgMs)
|
|
|
- {
|
|
|
- hw_uwChrgCt = 0;
|
|
|
- hw_blChrgOvrFlg = TRUE;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-/* Three phase short */
|
|
|
-void hw_voThrPhsShrt(void)
|
|
|
-{
|
|
|
- /* Set 0% duty */
|
|
|
- iPwm_SetCompareValue(0, 0, 0);
|
|
|
- iPwm_SetCompareValue(0, 1, 0);
|
|
|
- iPwm_SetCompareValue(0, 2, 0);
|
|
|
- iPwm_SetCompareValueDelay(0, 2, 0);
|
|
|
- iPwm_SetCompareValueDelay(0, 2, 0);
|
|
|
- iPwm_SetCompareValueDelay(0, 2, 0);
|
|
|
- iPwm_SetCompareValueImmediate(0, 2, 0);
|
|
|
- iPwm_SetCompareValueImmediate(0, 2, 0);
|
|
|
- iPwm_SetCompareValueImmediate(0, 2, 0);
|
|
|
- /* PWM on */
|
|
|
- hw_voPWMOn();
|
|
|
-}
|
|
|
/*************************************************************************
|
|
|
Function
|
|
|
Description: Initialize UART
|