diff --git a/boards/arm/mppt_2420_hpx/Kconfig.defconfig b/boards/arm/mppt_2420_hpx/Kconfig.defconfig index e7f97ae..e406bb4 100644 --- a/boards/arm/mppt_2420_hpx/Kconfig.defconfig +++ b/boards/arm/mppt_2420_hpx/Kconfig.defconfig @@ -10,10 +10,10 @@ config HAS_DCDC_CONVERTER default y config DCDC_PWM_FREQUENCY_KHZ - default 50 + default 70 config DCDC_PWM_DEADTIME_NS - default 230 + default 300 config HAS_LOAD_OUTPUT default y diff --git a/src/half_bridge.cpp b/src/half_bridge.cpp index 2611727..d445396 100644 --- a/src/half_bridge.cpp +++ b/src/half_bridge.cpp @@ -106,7 +106,7 @@ class PWM_TIM3 } }; -#elif defined(STM32F0) +#elif defined(STM32F0) || defined(STM32G4) class PWM_TIM1 { @@ -115,7 +115,11 @@ class PWM_TIM1 static void _init_registers(uint32_t pwm_resolution) { // Enable peripheral clock of GPIOA and GPIOB +#ifdef STM32F0 RCC->AHBENR |= RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN; +#else // STM32G4 + RCC->AHB2ENR |= RCC_AHB2ENR_GPIOAEN | RCC_AHB2ENR_GPIOBEN; +#endif // Enable TIM1 clock RCC->APB2ENR |= RCC_APB2ENR_TIM1EN; @@ -124,9 +128,13 @@ class PWM_TIM1 GPIOB->MODER = (GPIOB->MODER & ~(GPIO_MODER_MODER13)) | GPIO_MODER_MODER13_1; // Select AF2 on PA8 (TIM1_CH1) and PB13 (TIM1_CH1N) +#ifdef STM32F0 GPIOA->AFR[1] |= 0x2 << GPIO_AFRH_AFSEL8_Pos; GPIOB->AFR[1] |= 0x2 << GPIO_AFRH_AFSEL13_Pos; - +#else // STM32G4 + GPIOA->AFR[1] |= 0x6 << GPIO_AFRH_AFSEL8_Pos; + GPIOB->AFR[1] |= 0x6 << GPIO_AFRH_AFSEL13_Pos; +#endif // No prescaler --> timer frequency == SystemClock TIM1->PSC = 0; diff --git a/src/pcbs/mppt_2420_hpx_0v1.h b/src/pcbs/mppt_2420_hpx_0v1.h index e1bee64..d11401a 100644 --- a/src/pcbs/mppt_2420_hpx_0v1.h +++ b/src/pcbs/mppt_2420_hpx_0v1.h @@ -4,8 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#ifndef MPPT_1210_HUS_0V4_H -#define MPPT_1210_HUS_0V4_H +#ifndef MPPT_2420_HPX_0V1_H +#define MPPT_2420_HPX_0V1_H #ifdef __MBED__ #include "mbed.h" @@ -13,8 +13,8 @@ #include #endif -#define DEVICE_TYPE "MPPT-1210-HUS" -#define HARDWARE_VERSION "v0.4" +#define DEVICE_TYPE "MPPT-2420-HPX" +#define HARDWARE_VERSION "v0.1" // specify features of charge controller #define CONFIG_HAS_DCDC_CONVERTER 1 @@ -22,12 +22,12 @@ #define CONFIG_HAS_LOAD_OUTPUT 1 // DC/DC converter settings -#define PWM_FREQUENCY 50 // kHz 50 = better for cloud solar to increase efficiency -#define PWM_DEADTIME 230 // ns -//#define PWM_TIM 1 // use TIM1 timer +#define PWM_FREQUENCY 70 // kHz +#define PWM_DEADTIME 300 // ns +#define PWM_TIM 1 // use TIM1 timer -#define DCDC_CURRENT_MAX 10 // PCB maximum DCDC output current -#define LOAD_CURRENT_MAX 10 // PCB maximum load switch current +#define DCDC_CURRENT_MAX 20 // PCB maximum DCDC output current +#define LOAD_CURRENT_MAX 20 // PCB maximum load switch current #define LOW_SIDE_VOLTAGE_MAX 16 // Maximum voltage at battery port (V) #define HIGH_SIDE_VOLTAGE_MAX 55 // Maximum voltage at PV input port (V)