Razvalyaev
7e0063eee0
Все основные файлы подтянуты без изменений Изменены (только папка main_matlab): - заглушки для ненужных функций (main_matlab.c) - iq библиотека (IQmathLib_matlab.c) - библиотеки DSP281x
672 lines
21 KiB
C
672 lines
21 KiB
C
/*
|
|
* xp_write_xpwm_time.c
|
|
*
|
|
* Created on: 03 àïð. 2018 ã.
|
|
* Author: stud
|
|
*/
|
|
|
|
#include "xp_write_xpwm_time.h"
|
|
|
|
#include <project_setup.h>
|
|
|
|
#include "MemoryFunctions.h"
|
|
#include "Spartan2E_Adr.h"
|
|
#include "xerror.h"
|
|
|
|
|
|
|
|
|
|
#pragma DATA_SECTION(xpwm_time,".fast_vars1");
|
|
XPWM_TIME xpwm_time = DEFAULT_XPWM_TIME;
|
|
|
|
|
|
#define set_default_tclosed(k,b) {if (b) k = p->Tclosed_saw_direct_1; else k = p->Tclosed_saw_direct_0;}
|
|
///////////////////////////////////////////////////////
|
|
///////////////////////////////////////////////////////
|
|
///////////////////////////////////////////////////////
|
|
void set_mode_soft_x24(void)
|
|
{
|
|
i_WriteMemory(ADR_PWM_START_STOP, (i_ReadMemory(ADR_PWM_START_STOP) | 0x8000) );
|
|
}
|
|
|
|
void set_mode_hard_x24(void)
|
|
{
|
|
i_WriteMemory(ADR_PWM_START_STOP, (i_ReadMemory(ADR_PWM_START_STOP) & 0x7fff) );
|
|
}
|
|
|
|
void set_start_pwm_x24(void)
|
|
{
|
|
i_WriteMemory(ADR_PWM_START_STOP, (i_ReadMemory(ADR_PWM_START_STOP) | 0x0001) );
|
|
}
|
|
|
|
void set_stop_pwm_x24(void)
|
|
{
|
|
i_WriteMemory(ADR_PWM_START_STOP, (i_ReadMemory(ADR_PWM_START_STOP) & 0xfffe) );
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void initXpwmTimeStructure(XPWM_TIME *p)
|
|
{
|
|
|
|
set_default_tclosed(p->Ta0_0, p->saw_direct.bits.bit0);
|
|
set_default_tclosed(p->Ta0_1, p->saw_direct.bits.bit1);
|
|
set_default_tclosed(p->Tb0_0, p->saw_direct.bits.bit2);
|
|
set_default_tclosed(p->Tb0_1, p->saw_direct.bits.bit3);
|
|
set_default_tclosed(p->Tc0_0, p->saw_direct.bits.bit4);
|
|
set_default_tclosed(p->Tc0_1, p->saw_direct.bits.bit5);
|
|
|
|
set_default_tclosed(p->Ta1_0, p->saw_direct.bits.bit6);
|
|
set_default_tclosed(p->Ta1_1, p->saw_direct.bits.bit7);
|
|
set_default_tclosed(p->Tb1_0, p->saw_direct.bits.bit8);
|
|
set_default_tclosed(p->Tb1_1, p->saw_direct.bits.bit9);
|
|
set_default_tclosed(p->Tc1_0, p->saw_direct.bits.bit10);
|
|
set_default_tclosed(p->Tc1_1, p->saw_direct.bits.bit11);
|
|
|
|
p->Tbr0_0 = 0;
|
|
p->Tbr0_1 = 0;
|
|
p->Tbr1_0 = 0;
|
|
p->Tbr1_1 = 0;
|
|
|
|
if (p->freq_pwm == 0)
|
|
{
|
|
xerror(main_er_ID(2),(void *)1); // 0 íå ìîæåò áûòü!!!
|
|
}
|
|
|
|
|
|
p->inited = 1;
|
|
}
|
|
|
|
#pragma CODE_SECTION(xpwm_write_zero_1,".fast_run1");
|
|
void xpwm_write_zero_1(XPWM_TIME *p)
|
|
{
|
|
unsigned int tclose;
|
|
|
|
//a
|
|
set_default_tclosed(tclose, p->saw_direct.bits.bit0);
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_A1_PLUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, tclose);
|
|
p->Ta0_0 = tclose;
|
|
|
|
set_default_tclosed(tclose, p->saw_direct.bits.bit1);
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_A1_MINUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, tclose);
|
|
p->Ta0_1 = tclose;
|
|
|
|
set_default_tclosed(tclose, p->saw_direct.bits.bit2);
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_B1_PLUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, tclose);
|
|
p->Tb0_0 = tclose;
|
|
|
|
set_default_tclosed(tclose, p->saw_direct.bits.bit3);
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_B1_MINUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, tclose);
|
|
p->Tb0_1 = tclose;
|
|
|
|
set_default_tclosed(tclose, p->saw_direct.bits.bit4);
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_C1_PLUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, tclose);
|
|
p->Tc0_0 = tclose;
|
|
|
|
set_default_tclosed(tclose, p->saw_direct.bits.bit5);
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_C1_MINUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, tclose);
|
|
p->Tc0_1 = tclose;
|
|
|
|
}
|
|
|
|
#pragma CODE_SECTION(xpwm_write_zero_2,".fast_run1");
|
|
void xpwm_write_zero_2(XPWM_TIME *p)
|
|
{
|
|
unsigned int tclose;
|
|
|
|
//b
|
|
set_default_tclosed(tclose, p->saw_direct.bits.bit6);
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_A2_PLUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, tclose);
|
|
p->Ta1_0 = tclose;
|
|
|
|
set_default_tclosed(tclose, p->saw_direct.bits.bit7);
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_A2_MINUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, tclose);
|
|
p->Ta1_1 = tclose;
|
|
|
|
set_default_tclosed(tclose, p->saw_direct.bits.bit8);
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_B2_PLUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, tclose);
|
|
p->Tb1_0 = tclose;
|
|
|
|
set_default_tclosed(tclose, p->saw_direct.bits.bit9);
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_B2_MINUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, tclose);
|
|
p->Tb1_1 = tclose;
|
|
|
|
set_default_tclosed(tclose, p->saw_direct.bits.bit10);
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_C2_PLUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, tclose);
|
|
p->Tc1_0 = tclose;
|
|
|
|
set_default_tclosed(tclose, p->saw_direct.bits.bit11);
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_C2_MINUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, tclose);
|
|
p->Tc1_1 = tclose;
|
|
|
|
}
|
|
|
|
#pragma CODE_SECTION(xpwm_write_zero_break_1,".fast_run1");
|
|
void xpwm_write_zero_break_1(XPWM_TIME *p)
|
|
{
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_BR1_PLUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, 0);
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_BR1_MINUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, 0);
|
|
|
|
p->Tbr0_0 = 0;
|
|
p->Tbr0_1 = 0;
|
|
|
|
}
|
|
|
|
#pragma CODE_SECTION(xpwm_write_zero_break_2,".fast_run1");
|
|
void xpwm_write_zero_break_2(XPWM_TIME *p)
|
|
{
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_BR2_PLUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, 0);
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_BR2_MINUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, 0);
|
|
|
|
p->Tbr1_0 = 0;
|
|
p->Tbr1_1 = 0;
|
|
}
|
|
|
|
#pragma CODE_SECTION(xpwm_write_zero_winding_break_times_16_lines,".fast_run1");
|
|
void xpwm_write_zero_winding_break_times_16_lines(XPWM_TIME *p)
|
|
{
|
|
xpwm_write_zero_1(p);
|
|
xpwm_write_zero_2(p);
|
|
xpwm_write_zero_break_1(p);
|
|
xpwm_write_zero_break_2(p);
|
|
}
|
|
|
|
#pragma CODE_SECTION(xpwm_write_1_2_winding_break_times_16_lines,".fast_run1");
|
|
void xpwm_write_1_2_winding_break_times_16_lines(XPWM_TIME *p)
|
|
{
|
|
if (!(i_ReadMemory(ADR_ERRORS_TOTAL_INFO)))
|
|
{
|
|
//a
|
|
if ((p->mode_reload==PWM_MODE_RELOAD_FORCE)
|
|
|| (p->saw_direct.bits.bit0 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_HIGH)
|
|
|| (p->saw_direct.bits.bit0==0 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_LOW) )
|
|
{
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_A1_PLUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, p->Ta0_0);
|
|
}
|
|
|
|
if ((p->mode_reload==PWM_MODE_RELOAD_FORCE)
|
|
|| (p->saw_direct.bits.bit1 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_HIGH)
|
|
|| (p->saw_direct.bits.bit1==0 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_LOW) )
|
|
{
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_A1_MINUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, p->Ta0_1);
|
|
}
|
|
if ((p->mode_reload==PWM_MODE_RELOAD_FORCE)
|
|
|| (p->saw_direct.bits.bit2 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_HIGH)
|
|
|| (p->saw_direct.bits.bit2==0 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_LOW) )
|
|
{
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_B1_PLUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, p->Tb0_0);
|
|
}
|
|
if ((p->mode_reload==PWM_MODE_RELOAD_FORCE)
|
|
|| (p->saw_direct.bits.bit3 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_HIGH)
|
|
|| (p->saw_direct.bits.bit3==0 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_LOW) )
|
|
{
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_B1_MINUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, p->Tb0_1);
|
|
}
|
|
if ((p->mode_reload==PWM_MODE_RELOAD_FORCE)
|
|
|| (p->saw_direct.bits.bit4 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_HIGH)
|
|
|| (p->saw_direct.bits.bit4==0 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_LOW) )
|
|
{
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_C1_PLUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, p->Tc0_0);
|
|
}
|
|
if ((p->mode_reload==PWM_MODE_RELOAD_FORCE)
|
|
|| (p->saw_direct.bits.bit5 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_HIGH)
|
|
|| (p->saw_direct.bits.bit5==0 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_LOW) )
|
|
{
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_C1_MINUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, p->Tc0_1);
|
|
}
|
|
//b
|
|
if ((p->mode_reload==PWM_MODE_RELOAD_FORCE)
|
|
|| (p->saw_direct.bits.bit6 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_HIGH)
|
|
|| (p->saw_direct.bits.bit6==0 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_LOW) )
|
|
{
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_A2_PLUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, p->Ta1_0);
|
|
}
|
|
if ((p->mode_reload==PWM_MODE_RELOAD_FORCE)
|
|
|| (p->saw_direct.bits.bit7 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_HIGH)
|
|
|| (p->saw_direct.bits.bit7==0 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_LOW) )
|
|
{
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_A2_MINUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, p->Ta1_1);
|
|
}
|
|
if ((p->mode_reload==PWM_MODE_RELOAD_FORCE)
|
|
|| (p->saw_direct.bits.bit8 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_HIGH)
|
|
|| (p->saw_direct.bits.bit8==0 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_LOW) )
|
|
{
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_B2_PLUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, p->Tb1_0);
|
|
}
|
|
if ((p->mode_reload==PWM_MODE_RELOAD_FORCE)
|
|
|| (p->saw_direct.bits.bit9 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_HIGH)
|
|
|| (p->saw_direct.bits.bit9==0 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_LOW) )
|
|
{
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_B2_MINUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, p->Tb1_1);
|
|
}
|
|
if ((p->mode_reload==PWM_MODE_RELOAD_FORCE)
|
|
|| (p->saw_direct.bits.bit10 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_HIGH)
|
|
|| (p->saw_direct.bits.bit10==0 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_LOW) )
|
|
{
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_C2_PLUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, p->Tc1_0);
|
|
}
|
|
if ((p->mode_reload==PWM_MODE_RELOAD_FORCE)
|
|
|| (p->saw_direct.bits.bit11 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_HIGH)
|
|
|| (p->saw_direct.bits.bit11==0 && p->mode_reload==PWM_MODE_RELOAD_LEVEL_LOW) )
|
|
{
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_C2_MINUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, p->Tc1_1);
|
|
}
|
|
|
|
//br1 br2
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_BR1_PLUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, p->Tbr0_0);
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_BR1_MINUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, p->Tbr0_1);
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_BR2_PLUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, p->Tbr1_0);
|
|
i_WriteMemory(ADR_PWM_KEY_NUMBER, PWM_KEY_NUMBER_BR2_MINUS);
|
|
i_WriteMemory(ADR_PWM_TIMING, p->Tbr1_1);
|
|
}
|
|
else
|
|
{
|
|
hard_stop_x24_pwm_all();
|
|
xpwm_write_zero_winding_break_times_16_lines(p);
|
|
}
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Ðàçðåøåíèå âûõîäîâ ØÈÌà
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
#pragma CODE_SECTION(soft_start_x24_break_1,".fast_run2")
|
|
void soft_start_x24_break_1(void)
|
|
{
|
|
unsigned int mask_tk_lines;
|
|
|
|
mask_tk_lines = i_ReadMemory(ADR_TK_MASK_0);
|
|
mask_tk_lines &= ENABLE_PWM_BREAK_1;
|
|
|
|
set_mode_soft_x24();
|
|
|
|
i_WriteMemory(ADR_TK_MASK_0, mask_tk_lines);
|
|
|
|
set_start_pwm_x24();
|
|
|
|
// if (!(i_ReadMemory(ADR_PWM_START_STOP) & 0x1))
|
|
// i_WriteMemory(ADR_PWM_START_STOP, PWM_START_SOFT); // soft start
|
|
|
|
}
|
|
//////////////////////////////////////////////////////////////////////
|
|
#pragma CODE_SECTION(soft_start_x24_break_2,".fast_run2")
|
|
void soft_start_x24_break_2(void)
|
|
{
|
|
unsigned int mask_tk_lines;
|
|
|
|
mask_tk_lines = i_ReadMemory(ADR_TK_MASK_0);
|
|
mask_tk_lines &= ENABLE_PWM_BREAK_2;
|
|
|
|
set_mode_soft_x24();
|
|
|
|
i_WriteMemory(ADR_TK_MASK_0, mask_tk_lines);
|
|
|
|
set_start_pwm_x24();
|
|
|
|
// if (!(i_ReadMemory(ADR_PWM_START_STOP) & 0x1))
|
|
// i_WriteMemory(ADR_PWM_START_STOP, PWM_START_SOFT); // soft start
|
|
}
|
|
//////////////////////////////////////////////////////////////////////
|
|
#pragma CODE_SECTION(soft_start_x24_break_all,".fast_run2")
|
|
void soft_start_x24_break_all(void)
|
|
{
|
|
unsigned int mask_tk_lines;
|
|
|
|
mask_tk_lines = i_ReadMemory(ADR_TK_MASK_0);
|
|
mask_tk_lines &= ENABLE_PWM_BREAK_ALL;
|
|
|
|
set_mode_soft_x24();
|
|
i_WriteMemory(ADR_TK_MASK_0, mask_tk_lines);
|
|
|
|
set_start_pwm_x24();
|
|
|
|
// if (!(i_ReadMemory(ADR_PWM_START_STOP) & 0x1))
|
|
// i_WriteMemory(ADR_PWM_START_STOP, PWM_START_SOFT); // soft start
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////
|
|
|
|
#pragma CODE_SECTION(soft_start_x24_pwm_1,".fast_run");
|
|
void soft_start_x24_pwm_1(void)
|
|
{
|
|
unsigned int mask_tk_lines;
|
|
|
|
mask_tk_lines = i_ReadMemory(ADR_TK_MASK_0);
|
|
mask_tk_lines &= ENABLE_PWM_1;
|
|
|
|
#if (TK_DISABLE_OUTPUT_A1)
|
|
mask_tk_lines |= DISABLE_PWM_A1;
|
|
#endif
|
|
#if (TK_DISABLE_OUTPUT_B1)
|
|
mask_tk_lines |= DISABLE_PWM_B1;
|
|
#endif
|
|
#if (TK_DISABLE_OUTPUT_C1)
|
|
mask_tk_lines |= DISABLE_PWM_C1;
|
|
#endif
|
|
|
|
set_mode_soft_x24();
|
|
i_WriteMemory(ADR_TK_MASK_0, mask_tk_lines);
|
|
|
|
set_start_pwm_x24();
|
|
|
|
// if (!(i_ReadMemory(ADR_PWM_START_STOP) & 0x1))
|
|
// i_WriteMemory(ADR_PWM_START_STOP, PWM_START_SOFT); // soft start
|
|
|
|
}
|
|
//////////////////////////////////////////////////////////////////////
|
|
#pragma CODE_SECTION(soft_start_x24_pwm_2,".fast_run");
|
|
void soft_start_x24_pwm_2(void)
|
|
{
|
|
unsigned int mask_tk_lines;
|
|
// mPWM_b = 1;
|
|
|
|
mask_tk_lines = i_ReadMemory(ADR_TK_MASK_0);
|
|
mask_tk_lines &= ENABLE_PWM_2;
|
|
|
|
#if (TK_DISABLE_OUTPUT_A2)
|
|
mask_tk_lines |= DISABLE_PWM_A2;
|
|
#endif
|
|
#if (TK_DISABLE_OUTPUT_B2)
|
|
mask_tk_lines |= DISABLE_PWM_B2;
|
|
#endif
|
|
#if (TK_DISABLE_OUTPUT_C2)
|
|
mask_tk_lines |= DISABLE_PWM_C2;
|
|
#endif
|
|
|
|
set_mode_soft_x24();
|
|
i_WriteMemory(ADR_TK_MASK_0, mask_tk_lines);
|
|
set_start_pwm_x24();
|
|
|
|
// if (!(i_ReadMemory(ADR_PWM_START_STOP) & 0x1))
|
|
// i_WriteMemory(ADR_PWM_START_STOP, PWM_START_SOFT); // soft start
|
|
|
|
}
|
|
//////////////////////////////////////////////////////////////////////
|
|
#pragma CODE_SECTION(soft_start_x24_pwm_1_2,".fast_run");
|
|
void soft_start_x24_pwm_1_2(void)
|
|
{
|
|
unsigned int mask_tk_lines;
|
|
// mPWM_a = 1;
|
|
// mPWM_b = 1;
|
|
|
|
mask_tk_lines = i_ReadMemory(ADR_TK_MASK_0);
|
|
mask_tk_lines &= ENABLE_PWM_1_2;
|
|
|
|
#if (TK_DISABLE_OUTPUT_A1)
|
|
mask_tk_lines |= DISABLE_PWM_A1;
|
|
#endif
|
|
#if (TK_DISABLE_OUTPUT_B1)
|
|
mask_tk_lines |= DISABLE_PWM_B1;
|
|
#endif
|
|
#if (TK_DISABLE_OUTPUT_C1)
|
|
mask_tk_lines |= DISABLE_PWM_C1;
|
|
#endif
|
|
#if (TK_DISABLE_OUTPUT_A2)
|
|
mask_tk_lines |= DISABLE_PWM_A2;
|
|
#endif
|
|
#if (TK_DISABLE_OUTPUT_B2)
|
|
mask_tk_lines |= DISABLE_PWM_B2;
|
|
#endif
|
|
#if (TK_DISABLE_OUTPUT_C2)
|
|
mask_tk_lines |= DISABLE_PWM_C2;
|
|
#endif
|
|
|
|
set_mode_soft_x24();
|
|
i_WriteMemory(ADR_TK_MASK_0, mask_tk_lines);
|
|
set_start_pwm_x24();
|
|
|
|
// if (!(i_ReadMemory(ADR_PWM_START_STOP) & 0x1))
|
|
// i_WriteMemory(ADR_PWM_START_STOP, PWM_START_SOFT); // soft start
|
|
|
|
}
|
|
|
|
////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////
|
|
|
|
#pragma CODE_SECTION(soft_start_x24_pwm_all,".fast_run");
|
|
void soft_start_x24_pwm_all(void)
|
|
{
|
|
unsigned int mask_tk_lines;
|
|
// mPWM_a = 1;
|
|
// mPWM_b = 1;
|
|
|
|
mask_tk_lines = i_ReadMemory(ADR_TK_MASK_0);
|
|
mask_tk_lines &= ENABLE_PWM_ALL;
|
|
|
|
#if (TK_DISABLE_OUTPUT_A1)
|
|
mask_tk_lines |= DISABLE_PWM_A1;
|
|
#endif
|
|
#if (TK_DISABLE_OUTPUT_B1)
|
|
mask_tk_lines |= DISABLE_PWM_B1;
|
|
#endif
|
|
#if (TK_DISABLE_OUTPUT_C1)
|
|
mask_tk_lines |= DISABLE_PWM_C1;
|
|
#endif
|
|
#if (TK_DISABLE_OUTPUT_A2)
|
|
mask_tk_lines |= DISABLE_PWM_A2;
|
|
#endif
|
|
#if (TK_DISABLE_OUTPUT_B2)
|
|
mask_tk_lines |= DISABLE_PWM_B2;
|
|
#endif
|
|
#if (TK_DISABLE_OUTPUT_C2)
|
|
mask_tk_lines |= DISABLE_PWM_C2;
|
|
#endif
|
|
|
|
set_mode_soft_x24();
|
|
i_WriteMemory(ADR_TK_MASK_0, mask_tk_lines);
|
|
set_start_pwm_x24();
|
|
|
|
// if (!(i_ReadMemory(ADR_PWM_START_STOP) & 0x1))
|
|
// i_WriteMemory(ADR_PWM_START_STOP, PWM_START_SOFT); // soft start
|
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Çàïðåùåíèå âûõîäîâ ØÈÌà
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
#pragma CODE_SECTION(hard_stop_x24_pwm_all,".fast_run");
|
|
void hard_stop_x24_pwm_all(void)
|
|
{
|
|
unsigned int mask_tk_lines;
|
|
|
|
xpwm_write_zero_1(&xpwm_time);
|
|
xpwm_write_zero_2(&xpwm_time);
|
|
|
|
xpwm_write_zero_break_1(&xpwm_time);
|
|
xpwm_write_zero_break_2(&xpwm_time);
|
|
|
|
mask_tk_lines = i_ReadMemory(ADR_TK_MASK_0);
|
|
mask_tk_lines |= DISABLE_PWM_ALL;
|
|
|
|
set_mode_hard_x24();
|
|
i_WriteMemory(ADR_TK_MASK_0, mask_tk_lines);
|
|
set_stop_pwm_x24();
|
|
|
|
// i_WriteMemory(ADR_PWM_START_STOP, PWM_STOP_HARD);
|
|
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////
|
|
|
|
#pragma CODE_SECTION(soft_stop_x24_pwm_all,".fast_run");
|
|
void soft_stop_x24_pwm_all(void)
|
|
{
|
|
unsigned int mask_tk_lines;
|
|
|
|
xpwm_write_zero_1(&xpwm_time);
|
|
xpwm_write_zero_2(&xpwm_time);
|
|
|
|
xpwm_write_zero_break_1(&xpwm_time);
|
|
xpwm_write_zero_break_2(&xpwm_time);
|
|
|
|
mask_tk_lines = i_ReadMemory(ADR_TK_MASK_0);
|
|
mask_tk_lines |= DISABLE_PWM_ALL;
|
|
|
|
set_mode_soft_x24();
|
|
i_WriteMemory(ADR_TK_MASK_0, mask_tk_lines);
|
|
set_stop_pwm_x24();
|
|
|
|
// i_WriteMemory(ADR_PWM_START_STOP, PWM_STOP_SOFT);
|
|
|
|
}
|
|
//////////////////////////////////////////////////////////////////////
|
|
#pragma CODE_SECTION(soft_stop_x24_pwm_1_2,".fast_run");
|
|
void soft_stop_x24_pwm_1_2(void)
|
|
{
|
|
unsigned int mask_tk_lines;
|
|
|
|
xpwm_write_zero_1(&xpwm_time);
|
|
xpwm_write_zero_2(&xpwm_time);
|
|
|
|
mask_tk_lines = i_ReadMemory(ADR_TK_MASK_0);
|
|
mask_tk_lines |= DISABLE_PWM_1_2;
|
|
|
|
set_mode_soft_x24();
|
|
i_WriteMemory(ADR_TK_MASK_0, mask_tk_lines);
|
|
if (mask_tk_lines == DISABLE_PWM_ALL)
|
|
set_stop_pwm_x24();
|
|
// WriteMemory(ADR_PWM_START_STOP, PWM_STOP_SOFT);
|
|
|
|
}
|
|
//////////////////////////////////////////////////////////////////////
|
|
#pragma CODE_SECTION(soft_stop_x24_pwm_1,".fast_run");
|
|
void soft_stop_x24_pwm_1(void)
|
|
{
|
|
unsigned int mask_tk_lines;
|
|
|
|
xpwm_write_zero_1(&xpwm_time);
|
|
// xpwm_write_zero_2(&xpwm_time);
|
|
|
|
mask_tk_lines = i_ReadMemory(ADR_TK_MASK_0);
|
|
mask_tk_lines |= DISABLE_PWM_1;
|
|
|
|
set_mode_soft_x24();
|
|
i_WriteMemory(ADR_TK_MASK_0, mask_tk_lines);
|
|
if (mask_tk_lines == DISABLE_PWM_ALL)
|
|
set_stop_pwm_x24();
|
|
|
|
}
|
|
//////////////////////////////////////////////////////////////////////
|
|
#pragma CODE_SECTION(soft_stop_x24_pwm_2,".fast_run");
|
|
void soft_stop_x24_pwm_2(void)
|
|
{
|
|
unsigned int mask_tk_lines;
|
|
|
|
// xpwm_write_zero_1(&xpwm_time);
|
|
xpwm_write_zero_2(&xpwm_time);
|
|
|
|
mask_tk_lines = i_ReadMemory(ADR_TK_MASK_0);
|
|
mask_tk_lines |= DISABLE_PWM_2;
|
|
|
|
set_mode_soft_x24();
|
|
i_WriteMemory(ADR_TK_MASK_0, mask_tk_lines);
|
|
if (mask_tk_lines == DISABLE_PWM_ALL)
|
|
set_stop_pwm_x24();
|
|
}
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
#pragma CODE_SECTION(soft_stop_x24_break_1,".fast_run2")
|
|
void soft_stop_x24_break_1(void)
|
|
{
|
|
unsigned int mask_tk_lines;
|
|
|
|
xpwm_write_zero_break_1(&xpwm_time);
|
|
// xpwm_write_zero_break_2(&xpwm_time);
|
|
|
|
mask_tk_lines = i_ReadMemory(ADR_TK_MASK_0);
|
|
mask_tk_lines |= DISABLE_PWM_BREAK_1;
|
|
|
|
set_mode_soft_x24();
|
|
i_WriteMemory(ADR_TK_MASK_0, mask_tk_lines);
|
|
if (mask_tk_lines == DISABLE_PWM_ALL)
|
|
set_stop_pwm_x24();
|
|
|
|
}
|
|
//////////////////////////////////////////////////////////////////////
|
|
#pragma CODE_SECTION(soft_stop_x24_break_2,".fast_run2")
|
|
void soft_stop_x24_break_2(void)
|
|
{
|
|
unsigned int mask_tk_lines;
|
|
|
|
// xpwm_write_zero_break_1(&xpwm_time);
|
|
xpwm_write_zero_break_2(&xpwm_time);
|
|
|
|
mask_tk_lines = i_ReadMemory(ADR_TK_MASK_0);
|
|
mask_tk_lines |= DISABLE_PWM_BREAK_2;
|
|
|
|
set_mode_soft_x24();
|
|
i_WriteMemory(ADR_TK_MASK_0, mask_tk_lines);
|
|
if (mask_tk_lines == DISABLE_PWM_ALL)
|
|
set_stop_pwm_x24();
|
|
}
|
|
//////////////////////////////////////////////////////////////////////
|
|
#pragma CODE_SECTION(soft_stop_x24_break_all,".fast_run2")
|
|
void soft_stop_x24_break_all(void)
|
|
{
|
|
unsigned int mask_tk_lines;
|
|
|
|
xpwm_write_zero_break_1(&xpwm_time);
|
|
xpwm_write_zero_break_2(&xpwm_time);
|
|
|
|
mask_tk_lines = i_ReadMemory(ADR_TK_MASK_0);
|
|
mask_tk_lines |= DISABLE_PWM_BREAK_ALL;
|
|
|
|
set_mode_soft_x24();
|
|
i_WriteMemory(ADR_TK_MASK_0, mask_tk_lines);
|
|
if (mask_tk_lines == DISABLE_PWM_ALL)
|
|
set_stop_pwm_x24();
|
|
}
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
|