添加广播扫描连续两次响应的时间间隔,添加mppt各阶段切换,添加配置部分内容
This commit is contained in:
parent
d2a332e4af
commit
d2ae5c3b6d
|
@ -5,7 +5,7 @@
|
||||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="835033356658112547" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-156117377827207421" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
|
|
|
@ -11,6 +11,22 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#pragma pack(push,1)
|
#pragma pack(push,1)
|
||||||
|
|
||||||
|
typedef struct _uint8_config_info{
|
||||||
|
uint8_t start_Flag[2]; /* 起始标志 */
|
||||||
|
uint8_t address[7]; /* 地址 */
|
||||||
|
uint8_t end_Flag; /* 结束标志 */
|
||||||
|
uint8_t Access_Node_Type[2]; /* 接入节点类型 */
|
||||||
|
uint8_t Communication_Methods[2]; /* 通信方式 */
|
||||||
|
uint8_t bat485_Baud[4]; /* 串口波特率,为0代表bms不支持通信 */
|
||||||
|
uint8_t gw485_Baud[4]; /* 串口波特率 */
|
||||||
|
uint8_t ConstantCurrentV[2]; /* 高于该(电压 / 100),小于ConstantVoltageV * 100电压进行恒流充电 */
|
||||||
|
uint8_t ConstantVoltageV[2]; /* 高于该(电压 / 100)且电流大于FloatI * 100进行恒压充电 */
|
||||||
|
uint8_t FloatI[2]; /* 高于该(电压 / 100)且电流低于FloatI * 100进行浮充充电 */
|
||||||
|
uint8_t startSolarOpenCircuitV[2]; /* 高于该(电压 / 100)开始充电 */
|
||||||
|
}uint8_config_info;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _config_info{
|
typedef struct _config_info{
|
||||||
uint8_t start_Flag[2]; /* 起始标志 */
|
uint8_t start_Flag[2]; /* 起始标志 */
|
||||||
uint8_t address[7]; /* 地址 */
|
uint8_t address[7]; /* 地址 */
|
||||||
|
@ -19,6 +35,10 @@ typedef struct _config_info{
|
||||||
uint16_t Communication_Methods; /* 通信方式 */
|
uint16_t Communication_Methods; /* 通信方式 */
|
||||||
uint32_t bat485_Baud; /* 串口波特率 */
|
uint32_t bat485_Baud; /* 串口波特率 */
|
||||||
uint32_t gw485_Baud; /* 串口波特率 */
|
uint32_t gw485_Baud; /* 串口波特率 */
|
||||||
|
uint16_t ConstantCurrentV; /* 高于该(电压 / 100),小于ConstantVoltageV / 100电压进行恒流充电 */
|
||||||
|
uint16_t ConstantVoltageV; /* 高于该(电压 / 100)且电流大于FloatI / 100进行恒压充电 */
|
||||||
|
uint16_t FloatI; /* 高于该(电压 / 100)且电流低于FloatI / 100进行浮充充电 */
|
||||||
|
uint16_t startSolarOpenCircuitV;/* 高于该(电压 / 100)开始充电 */
|
||||||
}config_info;
|
}config_info;
|
||||||
#define CONFIG_INFO_SIZE (sizeof(config_info))
|
#define CONFIG_INFO_SIZE (sizeof(config_info))
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
|
@ -25,10 +25,20 @@ typedef struct _SL_Mppt_para{
|
||||||
extern SL_Mppt_para g_Mppt_Para;
|
extern SL_Mppt_para g_Mppt_Para;
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
|
||||||
|
/* mppt¹¤×÷ģʽ */
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
TRICKLE = 1, /* ä¸Á÷ģʽ */
|
||||||
|
CONSTANTCURRENT = 2, /* ºãÁ÷ģʽ */
|
||||||
|
CONSTANTVOLTAGE = 3, /* ºãѹģʽ */
|
||||||
|
FLOAT = 4, /* ¸¡³äģʽ */
|
||||||
|
}SL_MPPT_MODE;
|
||||||
|
|
||||||
extern float duty_ratio;
|
extern float duty_ratio;
|
||||||
|
|
||||||
|
|
||||||
void mppt_readJust(void);
|
void mppt_readJust(void);
|
||||||
|
void MpptMode(void);
|
||||||
void mppt_constantVoltage(float InVoltage);
|
void mppt_constantVoltage(float InVoltage);
|
||||||
void test(void);
|
void test(void);
|
||||||
|
|
||||||
|
|
|
@ -19,15 +19,15 @@
|
||||||
extern STR_TimeSliceOffset m_runled;
|
extern STR_TimeSliceOffset m_runled;
|
||||||
void Task_RunLED(void);
|
void Task_RunLED(void);
|
||||||
|
|
||||||
#define mpptControl_reloadVal 100 /* 任务执行间隔 */
|
#define mpptControl_reloadVal 1000 /* 任务执行间隔 */
|
||||||
#define mpptControl_offset 50 /* 任务执行偏移量 */
|
#define mpptControl_offset 0 /* 任务执行偏移量 */
|
||||||
extern STR_TimeSliceOffset m_mpptControl;
|
extern STR_TimeSliceOffset m_mpptControl;
|
||||||
void Task_mpptControl(void);
|
void Task_mpptControl(void);
|
||||||
|
|
||||||
#define usart_reloadVal 100 /* 任务执行间隔 */
|
#define usart_reloadVal 100 /* 任务执行间隔 */
|
||||||
#define usart_offset 1 /* 任务执行偏移量 */
|
#define usart_offset 0 /* 任务执行偏移量 */
|
||||||
extern STR_TimeSliceOffset m_usart;
|
extern STR_TimeSliceOffset m_usart;
|
||||||
extern uint8_t RegistrationRequestFlag;
|
extern uint8_t RegistrationRequestFlag; /* 接收到广播帧标志位 */
|
||||||
void Task_usart(void);
|
void Task_usart(void);
|
||||||
|
|
||||||
#define wdi_reloadVal 1000 /* 任务执行间隔 */
|
#define wdi_reloadVal 1000 /* 任务执行间隔 */
|
||||||
|
@ -36,7 +36,12 @@ void Task_usart(void);
|
||||||
extern STR_TimeSliceOffset m_wdi;
|
extern STR_TimeSliceOffset m_wdi;
|
||||||
void Task_wdi(void);
|
void Task_wdi(void);
|
||||||
|
|
||||||
#define recvbroadcast_reloadVal 5000 /* 任务执行间隔 */
|
#define refreshRegister_reloadVal 10000 /* 任务执行间隔 */
|
||||||
|
#define refreshRegister_offset 0 /* 任务执行偏移量 */
|
||||||
|
extern STR_TimeSliceOffset m_refreshRegister;
|
||||||
|
void Task_refreshRegister(void);
|
||||||
|
|
||||||
|
#define recvbroadcast_reloadVal 3000 /* 任务执行间隔 */
|
||||||
#define recvbroadcast_offset 0 /* 任务执行偏移量 */
|
#define recvbroadcast_offset 0 /* 任务执行偏移量 */
|
||||||
extern uint8_t recvbroadcast_flag; /* 是否需要再次发送标志 */
|
extern uint8_t recvbroadcast_flag; /* 是否需要再次发送标志 */
|
||||||
extern device_handle g_recvBroadcastDevice; /* 串口句柄 */
|
extern device_handle g_recvBroadcastDevice; /* 串口句柄 */
|
||||||
|
@ -44,7 +49,7 @@ extern uint8_t g_recvBroadcastRegisterNumber; /*
|
||||||
extern STR_TimeSliceOffset m_recvbroadcast;
|
extern STR_TimeSliceOffset m_recvbroadcast;
|
||||||
void Task_recvbroadcast(void);
|
void Task_recvbroadcast(void);
|
||||||
|
|
||||||
#define CapCharg_reloadVal 10000 /* 任务执行间隔 */
|
#define CapCharg_reloadVal 3000 /* 任务执行间隔 */
|
||||||
#define CapCharg_offset 0 /* 任务执行偏移量 */
|
#define CapCharg_offset 0 /* 任务执行偏移量 */
|
||||||
extern STR_TimeSliceOffset m_CapCharg;
|
extern STR_TimeSliceOffset m_CapCharg;
|
||||||
extern void Task_CapCharg(void);
|
extern void Task_CapCharg(void);
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#define MOSFET_Temper ADC_Channel_6
|
#define MOSFET_Temper ADC_Channel_6
|
||||||
#define PV2_VOLT_IN ADC_Channel_7
|
#define PV2_VOLT_IN ADC_Channel_7
|
||||||
|
|
||||||
//#define enable_Printf_VI
|
#define enable_Printf_VI
|
||||||
|
|
||||||
/* 光伏充电输出电流比例,放大倍数*电阻 */
|
/* 光伏充电输出电流比例,放大倍数*电阻 */
|
||||||
const float P_CHG_CURR = (1.0 / (50 * 0.005));
|
const float P_CHG_CURR = (1.0 / (50 * 0.005));
|
||||||
|
@ -84,6 +84,7 @@ float get_CHG_CURR(void)
|
||||||
|
|
||||||
I = (float)(I_ADC) / 4095 * 3.3 * P_CHG_CURR;
|
I = (float)(I_ADC) / 4095 * 3.3 * P_CHG_CURR;
|
||||||
|
|
||||||
|
// printf(" CHG_CURR I : %d /10000 \n", (int)(I * 10000));
|
||||||
#ifdef enable_Printf_VI
|
#ifdef enable_Printf_VI
|
||||||
printf("\n CHG_CURR ADC : %d \n", I_ADC);
|
printf("\n CHG_CURR ADC : %d \n", I_ADC);
|
||||||
printf(" CHG_CURR I : %d /10000 \n", (int)(I * 10000));
|
printf(" CHG_CURR I : %d /10000 \n", (int)(I * 10000));
|
||||||
|
|
|
@ -16,6 +16,10 @@ config_info g_slConfigInfo = {
|
||||||
.Communication_Methods = RS485,
|
.Communication_Methods = RS485,
|
||||||
.bat485_Baud = 9600,
|
.bat485_Baud = 9600,
|
||||||
.gw485_Baud = 9600,
|
.gw485_Baud = 9600,
|
||||||
|
.ConstantCurrentV = 1030,
|
||||||
|
.ConstantCurrentV = 1300,
|
||||||
|
.FloatI = 10,
|
||||||
|
.startSolarOpenCircuitV = 1800,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,6 @@ static void ConstantCurrentCharge(void);
|
||||||
static void ConstantVoltageCharge(void);
|
static void ConstantVoltageCharge(void);
|
||||||
static void FloatingCharge(void);
|
static void FloatingCharge(void);
|
||||||
|
|
||||||
#define TrickleV 10
|
|
||||||
#define ConstantCurrentV 13
|
|
||||||
#define ConstantVoltageV 14
|
|
||||||
#define FloatingV 14
|
|
||||||
|
|
||||||
float duty_ratio = 0.5;
|
float duty_ratio = 0.5;
|
||||||
/**
|
/**
|
||||||
* @brief 得到输出的功率
|
* @brief 得到输出的功率
|
||||||
|
@ -33,29 +28,6 @@ static float Get_OutputPower(void)
|
||||||
{
|
{
|
||||||
static float OutputPower;
|
static float OutputPower;
|
||||||
static float V_out, I_out;
|
static float V_out, I_out;
|
||||||
// float V_out_array[array_num];
|
|
||||||
// float I_out_array[array_num];
|
|
||||||
// float V_temp = 0;
|
|
||||||
// float I_temp = 0;
|
|
||||||
|
|
||||||
// for (int var = 0; var < array_num; ++var) {
|
|
||||||
// I_out_array[var] = get_CHG_CURR();
|
|
||||||
// V_out_array[var] = get_PV_VOLT_OUT();
|
|
||||||
// Delay_Ms(1);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for (int var = 0; var < array_num; ++var) {
|
|
||||||
// I_temp += I_out_array[var];
|
|
||||||
// V_temp += V_out_array[var];
|
|
||||||
// }
|
|
||||||
|
|
||||||
// for (int var = 0; var < array_num; ++var) {
|
|
||||||
// I_temp += get_CHG_CURR();
|
|
||||||
// V_temp += get_PV_VOLT_OUT();
|
|
||||||
// Delay_Ms(1);
|
|
||||||
// }
|
|
||||||
// V_out = V_temp / array_num;
|
|
||||||
// I_out = I_temp / array_num;
|
|
||||||
|
|
||||||
V_out = get_PV_VOLT_OUT();
|
V_out = get_PV_VOLT_OUT();
|
||||||
I_out = get_CHG_CURR();
|
I_out = get_CHG_CURR();
|
||||||
|
@ -79,8 +51,47 @@ const float step2_pwm = 0.001;
|
||||||
//#define array_num 10
|
//#define array_num 10
|
||||||
void mppt_readJust(void)
|
void mppt_readJust(void)
|
||||||
{
|
{
|
||||||
|
// static float last_duty_ratio = 0.5;
|
||||||
|
// static float now_duty_ratio;
|
||||||
|
// static float last_OutputPower;
|
||||||
|
// static float now_OutputPower;
|
||||||
|
// static float step_pwm = step1_pwm;
|
||||||
|
//
|
||||||
|
// last_OutputPower = Get_OutputPower();
|
||||||
|
//
|
||||||
|
// printf(" duty_ratio = %d/1000 \r\n", (int)(last_duty_ratio * 1000));
|
||||||
|
//
|
||||||
|
// /* 正向调节查看功率是否会变大 */
|
||||||
|
// now_duty_ratio = last_duty_ratio + step_pwm;
|
||||||
|
// if (now_duty_ratio > 1) {
|
||||||
|
// now_duty_ratio = 1;
|
||||||
|
// }
|
||||||
|
// Set_duty_ratio(now_duty_ratio);
|
||||||
|
// now_OutputPower = Get_OutputPower();
|
||||||
|
// if (now_OutputPower > last_OutputPower) {
|
||||||
|
// printf(" now_OutputPower > last_OutputPower1 \r\n");
|
||||||
|
// last_duty_ratio = now_duty_ratio;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /* 负向调节查看功率是否会变大 */
|
||||||
|
// now_duty_ratio = last_duty_ratio - step_pwm;
|
||||||
|
// if (now_duty_ratio < 0) {
|
||||||
|
// now_duty_ratio = 0;
|
||||||
|
// }
|
||||||
|
// Set_duty_ratio(now_duty_ratio);
|
||||||
|
// now_OutputPower = Get_OutputPower();
|
||||||
|
// if (now_OutputPower > last_OutputPower) {
|
||||||
|
// printf(" now_OutputPower > last_OutputPower2 \r\n");
|
||||||
|
// last_duty_ratio = now_duty_ratio;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /* 正负向调节功率均未变大,此时设置功率为原来的点 */
|
||||||
|
// Set_duty_ratio(last_duty_ratio);
|
||||||
|
//// step_pwm = step2_pwm;
|
||||||
|
|
||||||
static float last_duty_ratio = 0.5;
|
static float last_duty_ratio = 0.5;
|
||||||
static float now_duty_ratio;
|
|
||||||
static float last_OutputPower;
|
static float last_OutputPower;
|
||||||
static float now_OutputPower;
|
static float now_OutputPower;
|
||||||
static float step_pwm = step1_pwm;
|
static float step_pwm = step1_pwm;
|
||||||
|
@ -90,28 +101,28 @@ void mppt_readJust(void)
|
||||||
printf(" duty_ratio = %d/1000 \r\n", (int)(last_duty_ratio * 1000));
|
printf(" duty_ratio = %d/1000 \r\n", (int)(last_duty_ratio * 1000));
|
||||||
|
|
||||||
/* 正向调节查看功率是否会变大 */
|
/* 正向调节查看功率是否会变大 */
|
||||||
now_duty_ratio = last_duty_ratio + step_pwm;
|
duty_ratio = last_duty_ratio + step_pwm;
|
||||||
if (now_duty_ratio > 1) {
|
if (duty_ratio > 1) {
|
||||||
now_duty_ratio = 1;
|
duty_ratio = 1;
|
||||||
}
|
}
|
||||||
Set_duty_ratio(now_duty_ratio);
|
Set_duty_ratio(duty_ratio);
|
||||||
now_OutputPower = Get_OutputPower();
|
now_OutputPower = Get_OutputPower();
|
||||||
if (now_OutputPower > last_OutputPower) {
|
if (now_OutputPower > last_OutputPower) {
|
||||||
printf(" now_OutputPower > last_OutputPower1 \r\n");
|
printf(" now_OutputPower > last_OutputPower1 \r\n");
|
||||||
last_duty_ratio = now_duty_ratio;
|
last_duty_ratio = duty_ratio;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 负向调节查看功率是否会变大 */
|
/* 负向调节查看功率是否会变大 */
|
||||||
now_duty_ratio = last_duty_ratio - step_pwm;
|
duty_ratio = last_duty_ratio - step_pwm;
|
||||||
if (now_duty_ratio < 0) {
|
if (duty_ratio < 0) {
|
||||||
now_duty_ratio = 0;
|
duty_ratio = 0;
|
||||||
}
|
}
|
||||||
Set_duty_ratio(now_duty_ratio);
|
Set_duty_ratio(duty_ratio);
|
||||||
now_OutputPower = Get_OutputPower();
|
now_OutputPower = Get_OutputPower();
|
||||||
if (now_OutputPower > last_OutputPower) {
|
if (now_OutputPower > last_OutputPower) {
|
||||||
printf(" now_OutputPower > last_OutputPower2 \r\n");
|
printf(" now_OutputPower > last_OutputPower2 \r\n");
|
||||||
last_duty_ratio = now_duty_ratio;
|
last_duty_ratio = duty_ratio;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,30 +152,8 @@ void printf_data(void)
|
||||||
*/
|
*/
|
||||||
void mppt_constantVoltage(float InVoltage)
|
void mppt_constantVoltage(float InVoltage)
|
||||||
{
|
{
|
||||||
// float temp = get_PV_VOLT_OUT();
|
|
||||||
// Set_duty_ratio(0);
|
|
||||||
// Delay_Ms(500);
|
|
||||||
// float PV1_V = get_PV1_VOLT_IN();
|
|
||||||
//
|
|
||||||
// float constant_V = 0.78 * PV1_V;
|
|
||||||
//
|
|
||||||
// temp = temp / constant_V;
|
|
||||||
//
|
|
||||||
// Set_duty_ratio(temp);
|
|
||||||
|
|
||||||
// static float duty_ratio = 0.5;
|
|
||||||
static uint8_t ConstantVoltageFlag = 1;
|
static uint8_t ConstantVoltageFlag = 1;
|
||||||
// if (ConstantVoltageFlag) {
|
|
||||||
//// Set_duty_ratio(0);
|
|
||||||
//// Delay_Ms(500);
|
|
||||||
// float temp = get_PV_VOLT_OUT();
|
|
||||||
// temp = temp / InVoltage;
|
|
||||||
// Set_duty_ratio(temp);
|
|
||||||
// ConstantVoltageFlag = 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Set_duty_ratio(0);
|
|
||||||
// Delay_Ms(500);
|
|
||||||
float PV1_V = get_PV1_VOLT_IN();
|
float PV1_V = get_PV1_VOLT_IN();
|
||||||
|
|
||||||
if (ConstantVoltageFlag) {
|
if (ConstantVoltageFlag) {
|
||||||
|
@ -205,7 +194,6 @@ void mppt_constantVoltage(float InVoltage)
|
||||||
void TrickleCharge(void)
|
void TrickleCharge(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -216,8 +204,7 @@ void TrickleCharge(void)
|
||||||
*/
|
*/
|
||||||
void ConstantCurrentCharge(void)
|
void ConstantCurrentCharge(void)
|
||||||
{
|
{
|
||||||
|
mppt_readJust();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -228,8 +215,7 @@ void ConstantCurrentCharge(void)
|
||||||
*/
|
*/
|
||||||
void ConstantVoltageCharge(void)
|
void ConstantVoltageCharge(void)
|
||||||
{
|
{
|
||||||
|
mppt_constantVoltage(17.5);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -240,33 +226,79 @@ void ConstantVoltageCharge(void)
|
||||||
*/
|
*/
|
||||||
void FloatingCharge(void)
|
void FloatingCharge(void)
|
||||||
{
|
{
|
||||||
|
mppt_constantVoltage(16);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint8_t modeFlag = 0;
|
||||||
void MpptContorl(void)
|
void MpptContorl(void)
|
||||||
{
|
{
|
||||||
/* 后续可以添加考虑减少放电电流的影响,或停止放电的时候判断 */
|
switch(modeFlag) {
|
||||||
float OutputVoltage = get_PV_VOLT_OUT();
|
case TRICKLE:
|
||||||
|
|
||||||
if (TrickleV > OutputVoltage) {
|
|
||||||
TrickleCharge();
|
TrickleCharge();
|
||||||
} else if (ConstantCurrentV > OutputVoltage) {
|
break;
|
||||||
|
|
||||||
|
case CONSTANTCURRENT:
|
||||||
ConstantCurrentCharge();
|
ConstantCurrentCharge();
|
||||||
} else if (ConstantVoltageV > OutputVoltage) {
|
break;
|
||||||
|
|
||||||
|
case CONSTANTVOLTAGE:
|
||||||
ConstantVoltageCharge();
|
ConstantVoltageCharge();
|
||||||
} else {
|
break;
|
||||||
|
|
||||||
|
case FLOAT:
|
||||||
FloatingCharge();
|
FloatingCharge();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MpptMode(void)
|
||||||
|
{
|
||||||
|
static uint8_t temp_flag = 1;
|
||||||
|
static float ConstantCurrentV;
|
||||||
|
static float ConstantVoltageV;
|
||||||
|
static float FloatI;
|
||||||
|
if (temp_flag) {
|
||||||
|
ConstantCurrentV = (float)g_slConfigInfo.ConstantCurrentV / 100;
|
||||||
|
ConstantVoltageV = (float)g_slConfigInfo.ConstantVoltageV / 100;
|
||||||
|
FloatI = (float)g_slConfigInfo.FloatI / 100;
|
||||||
|
temp_flag = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((ConstantCurrentV < g_Mppt_Para.Battery_Voltage) &&
|
||||||
|
(ConstantVoltageV > g_Mppt_Para.Battery_Voltage)) {
|
||||||
|
modeFlag = CONSTANTCURRENT;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(ConstantVoltageV > g_Mppt_Para.Battery_Voltage) &&
|
||||||
|
(FloatI < get_CHG_CURR())) {
|
||||||
|
modeFlag = CONSTANTVOLTAGE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(ConstantVoltageV > g_Mppt_Para.Battery_Voltage) &&
|
||||||
|
(FloatI > get_CHG_CURR())) {
|
||||||
|
modeFlag = FLOAT;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
modeFlag = TRICKLE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void test(void)
|
void test(void)
|
||||||
{
|
{
|
||||||
// mppt_readjust();
|
// mppt_readjust();
|
||||||
// Get_OutputPower();
|
// Get_OutputPower();
|
||||||
|
// mppt_constantVoltage(18);
|
||||||
|
|
||||||
mppt_constantVoltage(18);
|
// MpptContorl();
|
||||||
// printf_data();
|
|
||||||
|
printf_data();
|
||||||
// void MpptContorl();
|
// void MpptContorl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "mppt_control.h"
|
#include "mppt_control.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
#include "tim.h"
|
||||||
|
|
||||||
|
|
||||||
/* 静态函数申明 */
|
/* 静态函数申明 */
|
||||||
|
@ -293,11 +294,10 @@ void SL_MsgProcFunc_Broadcast_Scan(device_handle device, void *pMsg, uint32_t Ms
|
||||||
|
|
||||||
RegistrationRequestFlag = 1;
|
RegistrationRequestFlag = 1;
|
||||||
|
|
||||||
/* 时间间隔设置为10ms,快速进入发送注册请求帧,在函数内部将时间间隔改为3s */
|
/* 任务创立后,立即执行一次 */
|
||||||
|
m_recvbroadcast.runFlag = 1;
|
||||||
TimeSliceOffset_Register(&m_recvbroadcast, Task_recvbroadcast \
|
TimeSliceOffset_Register(&m_recvbroadcast, Task_recvbroadcast \
|
||||||
, 10, recvbroadcast_offset);
|
, recvbroadcast_reloadVal, recvbroadcast_offset);
|
||||||
// TimeSliceOffset_Register(&m_recvbroadcast, Task_recvbroadcast \
|
|
||||||
// , recvbroadcast_reloadVal, recvbroadcast_offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SL_MsgProcFunc_Registration_request(device_handle device, void *pMsg, uint32_t MsgLen)
|
void SL_MsgProcFunc_Registration_request(device_handle device, void *pMsg, uint32_t MsgLen)
|
||||||
|
@ -308,6 +308,10 @@ void SL_MsgProcFunc_Registration_request(device_handle device, void *pMsg, uint3
|
||||||
TimeSliceOffset_Unregister(&m_recvbroadcast);
|
TimeSliceOffset_Unregister(&m_recvbroadcast);
|
||||||
SL_Mppt_RegistrationReply_pack *rpack = (SL_Mppt_RegistrationReply_pack *)pMsg;
|
SL_Mppt_RegistrationReply_pack *rpack = (SL_Mppt_RegistrationReply_pack *)pMsg;
|
||||||
g_Mppt_Para.Registration_Status = chang_8_to_16(rpack->registration_Status_L, rpack->registration_Status_H);
|
g_Mppt_Para.Registration_Status = chang_8_to_16(rpack->registration_Status_L, rpack->registration_Status_H);
|
||||||
|
|
||||||
|
/* 20s内不再接收广播帧 */
|
||||||
|
run_Broadcast = 0;
|
||||||
|
TIM2_Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -616,20 +620,22 @@ static int uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, uint3
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SuccessRegistrationAcceptScan
|
#ifdef SuccessRegistrationAcceptScan
|
||||||
/* 广播扫描 */
|
if (run_Broadcast) {
|
||||||
else if (pack->function_Code == SL_Function_Code_Broadcast_Scan) {
|
/* 广播扫描 */
|
||||||
log_info("Broadcast_Scan\r\n");
|
if (pack->function_Code == SL_Function_Code_Broadcast_Scan) {
|
||||||
len = SL_MPPT_SCAN_BROADCAST_PACK_SIZE;
|
log_info("Broadcast_Scan\r\n");
|
||||||
w_Flag = 0;
|
len = SL_MPPT_SCAN_BROADCAST_PACK_SIZE;
|
||||||
// continue;
|
w_Flag = 0;
|
||||||
}
|
// continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* 注册请求 */
|
/* 注册请求 */
|
||||||
else if (pack->function_Code == SL_Function_Code_Registration_request) {
|
else if (pack->function_Code == SL_Function_Code_Registration_request) {
|
||||||
log_info("Registration_request\r\n");
|
log_info("Registration_request\r\n");
|
||||||
len = SL_MPPT_REGISTRATIONREPLY_PACK_SIZE;
|
len = SL_MPPT_REGISTRATIONREPLY_PACK_SIZE;
|
||||||
w_Flag = 0;
|
w_Flag = 0;
|
||||||
// continue;
|
// continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
124
App/src/task.c
124
App/src/task.c
|
@ -30,7 +30,7 @@
|
||||||
STR_TimeSliceOffset m_runled;
|
STR_TimeSliceOffset m_runled;
|
||||||
void Task_RunLED(void)
|
void Task_RunLED(void)
|
||||||
{
|
{
|
||||||
printf("duty_ratio : %d \n", (int)(duty_ratio * 1000));
|
// printf("duty_ratio : %d \n", (int)(duty_ratio * 1000));
|
||||||
static uint8_t flag = RESET;
|
static uint8_t flag = RESET;
|
||||||
flag = !flag;
|
flag = !flag;
|
||||||
GPIO_WriteBit(RUN_LED_GPIO, RUN_LED_PIN, flag);
|
GPIO_WriteBit(RUN_LED_GPIO, RUN_LED_PIN, flag);
|
||||||
|
@ -46,8 +46,15 @@ void Task_RunLED(void)
|
||||||
STR_TimeSliceOffset m_mpptControl;
|
STR_TimeSliceOffset m_mpptControl;
|
||||||
void Task_mpptControl(void)
|
void Task_mpptControl(void)
|
||||||
{
|
{
|
||||||
// uart_dev_write(g_gw485_uart4_handle, "hello world \n", sizeof("hello world \n"));
|
// test();
|
||||||
test();
|
static uint8_t test_flag = 0;
|
||||||
|
if (5 == ++test_flag) {
|
||||||
|
test_flag = 0;
|
||||||
|
printf("in time init \n");
|
||||||
|
TIM2_Init();
|
||||||
|
printf("out time init \n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +68,6 @@ STR_TimeSliceOffset m_usart;
|
||||||
uint8_t RegistrationRequestFlag = 0;
|
uint8_t RegistrationRequestFlag = 0;
|
||||||
void Task_usart(void)
|
void Task_usart(void)
|
||||||
{
|
{
|
||||||
// printf(" task3******** \n");
|
|
||||||
read_and_process_uart_data(g_gw485_uart4_handle);
|
read_and_process_uart_data(g_gw485_uart4_handle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -84,6 +90,66 @@ void Task_wdi(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 刷新寄存器中的数据,同时刷新一下mppt工作模式
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
#define checkRemainingBatteryBower 3 //电池剩余电量30s刷新一次
|
||||||
|
#define checkSolarOpenCircuitVoltage 180 //太阳能板开路电压30min刷新一次
|
||||||
|
#define mpptmodedelay 6 //mppt工作模式60s刷新一次(小于1000S)
|
||||||
|
#define checkSolarOpenCircuitDelay 500 //检测太阳能板开路电压时,关闭太阳能板的延时时间
|
||||||
|
STR_TimeSliceOffset m_refreshRegister;
|
||||||
|
void Task_refreshRegister(void)
|
||||||
|
{
|
||||||
|
static uint8_t checkFlagTemp1 = 0;
|
||||||
|
static uint8_t checkFlagTemp2 = 0;
|
||||||
|
static uint8_t mpptModeFlag = 0;
|
||||||
|
|
||||||
|
/* 后续可以添加考虑减少放电电流的影响 */
|
||||||
|
g_Mppt_Para.Battery_Voltage = get_PV_VOLT_OUT();
|
||||||
|
g_Mppt_Para.Battery_temperature = 0;
|
||||||
|
|
||||||
|
if (checkRemainingBatteryBower == ++checkFlagTemp1) {
|
||||||
|
g_Mppt_Para.Remaining_Battery_Bower = 0;
|
||||||
|
checkFlagTemp1 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkSolarOpenCircuitVoltage == ++checkFlagTemp2) {
|
||||||
|
Set_duty_ratio(0);
|
||||||
|
Delay_Ms(500);
|
||||||
|
GPIO_WriteBit(G_FFMOS_CON1_GPIO, G_FFMOS_CON1_PIN, SET);
|
||||||
|
GPIO_WriteBit(G_FFMOS_CON2_GPIO, G_FFMOS_CON2_PIN, SET);
|
||||||
|
g_Mppt_Para.Solar_Open_Circuit_Voltage1 = get_PV1_VOLT_IN();
|
||||||
|
g_Mppt_Para.Solar_Open_Circuit_Voltage2 = get_PV2_VOLT_IN();
|
||||||
|
GPIO_WriteBit(G_FFMOS_CON1_GPIO, G_FFMOS_CON1_PIN, SET);
|
||||||
|
GPIO_WriteBit(G_FFMOS_CON2_GPIO, G_FFMOS_CON2_PIN, SET);
|
||||||
|
checkFlagTemp2 = 0;
|
||||||
|
|
||||||
|
if ((g_Mppt_Para.Solar_Open_Circuit_Voltage1
|
||||||
|
> g_slConfigInfo.startSolarOpenCircuitV)
|
||||||
|
|| (g_Mppt_Para.Solar_Open_Circuit_Voltage2
|
||||||
|
> g_slConfigInfo.startSolarOpenCircuitV)) {
|
||||||
|
TimeSliceOffset_Register(&m_mpptControl, Task_mpptControl
|
||||||
|
, mpptControl_reloadVal, mpptControl_offset);
|
||||||
|
mpptModeFlag = 0;
|
||||||
|
} else {
|
||||||
|
TimeSliceOffset_Unregister(&m_mpptControl);
|
||||||
|
mpptModeFlag = 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mpptModeFlag != 100) {
|
||||||
|
if (mpptmodedelay == ++mpptModeFlag) {
|
||||||
|
MpptMode();
|
||||||
|
mpptModeFlag = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 接收到广播指令后,发送数据给网关,未接收到指令再次发送,最多三次,间隔时间3s
|
* @brief 接收到广播指令后,发送数据给网关,未接收到指令再次发送,最多三次,间隔时间3s
|
||||||
* @param
|
* @param
|
||||||
|
@ -95,7 +161,6 @@ uint8_t g_recvBroadcastRegisterNumber;
|
||||||
STR_TimeSliceOffset m_recvbroadcast;
|
STR_TimeSliceOffset m_recvbroadcast;
|
||||||
void Task_recvbroadcast(void)
|
void Task_recvbroadcast(void)
|
||||||
{
|
{
|
||||||
m_recvbroadcast.count = recvbroadcast_reloadVal;
|
|
||||||
static uint8_t run_number = 0;
|
static uint8_t run_number = 0;
|
||||||
/* 超过三次,不再发送 */
|
/* 超过三次,不再发送 */
|
||||||
if (run_number++ == 3 || run_number > 3) {
|
if (run_number++ == 3 || run_number > 3) {
|
||||||
|
@ -192,27 +257,25 @@ void Task_CapCharg(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
Set_duty_ratio(0);
|
Set_duty_ratio(0);
|
||||||
for (uint8_t var = 0; var < 2; ++var) {
|
for (uint8_t var = 0; var < 3; ++var) {
|
||||||
Delay_Us(1);
|
Delay_Us(1);
|
||||||
GPIO_WriteBit(CAPCHARG_GPIO, CAPCHARG_PIN, SET);
|
GPIO_WriteBit(CAPCHARG_GPIO, CAPCHARG_PIN, SET);
|
||||||
Delay_Us(1);
|
Delay_Us(1);
|
||||||
GPIO_WriteBit(CAPCHARG_GPIO, CAPCHARG_PIN, RESET);
|
GPIO_WriteBit(CAPCHARG_GPIO, CAPCHARG_PIN, RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
duty_ratio = 0.9;
|
// duty_ratio = 0.9;
|
||||||
Set_duty_ratio(duty_ratio);
|
// Set_duty_ratio(duty_ratio);
|
||||||
|
TIM_SetCompare4(TIM4, 180);
|
||||||
|
|
||||||
if (30 == ++runNum) {
|
if (3 == ++runNum) {
|
||||||
runNum = 0;
|
runNum = 0;
|
||||||
m_CapCharg.reloadVal = CapCharg_reloadVal;
|
m_CapCharg.reloadVal = CapCharg_reloadVal;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("in test \n");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -248,20 +311,27 @@ void task_Init(void)
|
||||||
{
|
{
|
||||||
read_config_info();
|
read_config_info();
|
||||||
g_Mppt_Para_Init();
|
g_Mppt_Para_Init();
|
||||||
//
|
|
||||||
TimeSliceOffset_Register(&m_runled, Task_RunLED, runled_reloadVal, runled_offset);
|
|
||||||
TimeSliceOffset_Register(&m_mpptControl, Task_mpptControl, mpptControl_reloadVal, mpptControl_offset);
|
|
||||||
TimeSliceOffset_Register(&m_usart, Task_usart, usart_reloadVal, usart_offset);
|
|
||||||
TimeSliceOffset_Register(&m_wdi, Task_wdi, wdi_reloadVal, wdi_offset);
|
|
||||||
TimeSliceOffset_Register(&m_CapCharg, Task_CapCharg, CapCharg_reloadVal, CapCharg_offset);
|
|
||||||
//
|
|
||||||
TimeSliceOffset_Start(); /* Æô¶¯Ê±¼äƬÂÖѯ */
|
|
||||||
|
|
||||||
// while(1)
|
|
||||||
// {
|
TimeSliceOffset_Register(&m_runled, Task_RunLED, runled_reloadVal, runled_offset);
|
||||||
// Task_RunLED();
|
|
||||||
// Delay_Ms(1000);
|
|
||||||
// }
|
|
||||||
|
// m_refreshRegister.runFlag = 1; /* 该启动后立即执行一次 */
|
||||||
|
// TimeSliceOffset_Register(&m_refreshRegister, Task_refreshRegister
|
||||||
|
// , refreshRegister_reloadVal, refreshRegister_offset);
|
||||||
|
//
|
||||||
|
TimeSliceOffset_Register(&m_mpptControl, Task_mpptControl
|
||||||
|
, mpptControl_reloadVal, mpptControl_offset);
|
||||||
|
//
|
||||||
|
// TimeSliceOffset_Register(&m_usart, Task_usart, usart_reloadVal, usart_offset);
|
||||||
|
//
|
||||||
|
// TimeSliceOffset_Register(&m_wdi, Task_wdi, wdi_reloadVal, wdi_offset);
|
||||||
|
//
|
||||||
|
// TimeSliceOffset_Register(&m_CapCharg, Task_CapCharg, CapCharg_reloadVal, CapCharg_offset);
|
||||||
|
|
||||||
|
|
||||||
|
TimeSliceOffset_Start(); /* 启动时间片轮询 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -284,8 +354,6 @@ void hardware_Init(void)
|
||||||
DSG_PROT_Init();
|
DSG_PROT_Init();
|
||||||
SPI_Flash_Init();
|
SPI_Flash_Init();
|
||||||
|
|
||||||
Set_duty_ratio(0.5);
|
|
||||||
//
|
|
||||||
CAPCHARG_Init();
|
CAPCHARG_Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,13 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern uint8_t run_Broadcast;
|
||||||
|
|
||||||
void TIM3_Init(void);
|
void TIM3_Init(void);
|
||||||
void TIM3_Int_Init(uint16_t arr,uint16_t psc);
|
void TIM3_Int_Init(uint16_t arr,uint16_t psc);
|
||||||
|
|
||||||
|
void TIM2_Init(void);
|
||||||
|
void TIM2_Int_Init(uint16_t arr,uint16_t psc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* HARDWARE_INC_TIM_H_ */
|
#endif /* HARDWARE_INC_TIM_H_ */
|
||||||
|
|
|
@ -12,7 +12,13 @@
|
||||||
/* 时间基准为1ms,1ms切换一次任务 */
|
/* 时间基准为1ms,1ms切换一次任务 */
|
||||||
#define delayms 1
|
#define delayms 1
|
||||||
|
|
||||||
|
/* 延时时间 */
|
||||||
|
#define delays 2
|
||||||
|
|
||||||
|
uint8_t run_Broadcast = 1;
|
||||||
|
|
||||||
void TIM3_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
void TIM3_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||||
|
void TIM2_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||||
|
|
||||||
void TIM3_Init(void)
|
void TIM3_Init(void)
|
||||||
{
|
{
|
||||||
|
@ -32,7 +38,7 @@ void TIM3_Int_Init(uint16_t arr, uint16_t psc)
|
||||||
RCC_PB1PeriphClockCmd(RCC_PB1Periph_TIM3, ENABLE); //使能TIM3时钟
|
RCC_PB1PeriphClockCmd(RCC_PB1Periph_TIM3, ENABLE); //使能TIM3时钟
|
||||||
|
|
||||||
TIM_TimeBaseStructure.TIM_Period = arr; //指定下次更新事件时要加载到活动自动重新加载寄存器中的周期值。
|
TIM_TimeBaseStructure.TIM_Period = arr; //指定下次更新事件时要加载到活动自动重新加载寄存器中的周期值。
|
||||||
TIM_TimeBaseStructure.TIM_Prescaler =psc; //指定用于划分TIM时钟的预分频器值。
|
TIM_TimeBaseStructure.TIM_Prescaler = psc; //指定用于划分TIM时钟的预分频器值。
|
||||||
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; //时钟分频因子
|
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; //时钟分频因子
|
||||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //TIM计数模式,向上计数模式
|
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //TIM计数模式,向上计数模式
|
||||||
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); //根据指定的参数初始化TIMx的时间基数单位
|
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); //根据指定的参数初始化TIMx的时间基数单位
|
||||||
|
@ -77,3 +83,48 @@ void TIM3_IRQHandler(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TIM2_Init(void)
|
||||||
|
{
|
||||||
|
/* 分频系数 */
|
||||||
|
uint16_t psc = (SystemCoreClock / 1000) - 1;
|
||||||
|
/* 周期值 */
|
||||||
|
uint16_t arr = delays * 1000 - 1;
|
||||||
|
|
||||||
|
TIM2_Int_Init(arr, psc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TIM2_Int_Init(uint16_t arr, uint16_t psc)
|
||||||
|
{
|
||||||
|
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
||||||
|
NVIC_InitTypeDef NVIC_InitStructure;
|
||||||
|
|
||||||
|
RCC_PB1PeriphClockCmd(RCC_PB1Periph_TIM2, ENABLE); //使能TIM2时钟
|
||||||
|
|
||||||
|
TIM_TimeBaseStructure.TIM_Period = arr; //指定下次更新事件时要加载到活动自动重新加载寄存器中的周期值。
|
||||||
|
TIM_TimeBaseStructure.TIM_Prescaler = psc; //指定用于划分TIM时钟的预分频器值。
|
||||||
|
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; //时钟分频因子
|
||||||
|
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //TIM计数模式,向上计数模式
|
||||||
|
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure); //根据指定的参数初始化TIMx的时间基数单位
|
||||||
|
|
||||||
|
TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE); //使能TIM2中断,允许更新中断
|
||||||
|
|
||||||
|
//初始化TIM NVIC,设置中断优先级分组
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn; //TIM2中断
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; //设置抢占优先级0
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //设置响应优先级3
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //使能通道1中断
|
||||||
|
NVIC_Init(&NVIC_InitStructure); //初始化NVIC
|
||||||
|
|
||||||
|
TIM_Cmd(TIM2, ENABLE); //TIM2使能
|
||||||
|
}
|
||||||
|
|
||||||
|
void TIM2_IRQHandler(void)
|
||||||
|
{
|
||||||
|
if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET) { //检查TIM2中断是否发生。
|
||||||
|
TIM_ClearITPendingBit(TIM2, TIM_IT_Update); //清除TIM2的中断挂起位。
|
||||||
|
TIM_Cmd(TIM2, DISABLE); //TIM2禁止
|
||||||
|
TIM_ITConfig(TIM2, TIM_IT_Update, DISABLE); //禁止TIM2更新中断
|
||||||
|
printf("in time it \n");
|
||||||
|
run_Broadcast = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -32,7 +32,7 @@ App/src/sl_protocol.o: ../App/src/sl_protocol.c \
|
||||||
D:\psx\MPPT\git\App\inc/pdebug.h D:\psx\MPPT\git\App\inc/mppt_control.h \
|
D:\psx\MPPT\git\App\inc/pdebug.h D:\psx\MPPT\git\App\inc/mppt_control.h \
|
||||||
D:\psx\MPPT\git\App\inc/task.h \
|
D:\psx\MPPT\git\App\inc/task.h \
|
||||||
D:\psx\MPPT\git\Drivers\TimeSliceOffset/timeSliceOffset.h \
|
D:\psx\MPPT\git\Drivers\TimeSliceOffset/timeSliceOffset.h \
|
||||||
D:\psx\MPPT\git\App\inc/uart_dev.h
|
D:\psx\MPPT\git\App\inc/uart_dev.h D:\psx\MPPT\git\Hardware\inc/tim.h
|
||||||
|
|
||||||
D:\psx\MPPT\git\App\inc/sl_protocol.h:
|
D:\psx\MPPT\git\App\inc/sl_protocol.h:
|
||||||
|
|
||||||
|
@ -109,3 +109,5 @@ D:\psx\MPPT\git\App\inc/task.h:
|
||||||
D:\psx\MPPT\git\Drivers\TimeSliceOffset/timeSliceOffset.h:
|
D:\psx\MPPT\git\Drivers\TimeSliceOffset/timeSliceOffset.h:
|
||||||
|
|
||||||
D:\psx\MPPT\git\App\inc/uart_dev.h:
|
D:\psx\MPPT\git\App\inc/uart_dev.h:
|
||||||
|
|
||||||
|
D:\psx\MPPT\git\Hardware\inc/tim.h:
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
obj/User/main.o
BIN
obj/User/main.o
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
12994
obj/mppt_Nos_V0.4.lst
12994
obj/mppt_Nos_V0.4.lst
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue