This commit is contained in:
David Rice
2026-01-28 12:16:24 +00:00
parent c01006628f
commit 869aba188a
14 changed files with 14717 additions and 15385 deletions

View File

@@ -63,9 +63,7 @@ void Error_Handler(void);
#define USART2_TX_GPIO_Port GPIOA
#define USART2_RX_Pin GPIO_PIN_3
#define USART2_RX_GPIO_Port GPIOA
#define VIN_Pin GPIO_PIN_6
#define VIN_GPIO_Port GPIOA
#define VOUT_Pin GPIO_PIN_7
#define VOUT_Pin GPIO_PIN_6
#define VOUT_GPIO_Port GPIOA
#define T_SWDIO_Pin GPIO_PIN_13
#define T_SWDIO_GPIO_Port GPIOA

View File

@@ -21,19 +21,22 @@
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "stm32g4xx_hal.h"
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#define AVG_WINDOW 32
#define FILTER_SIZE 128 /* Must be a power of 2 for optimal bit-shifting (e.g., 8, 16, 32, 64) */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
typedef struct
{
uint16_t buffer[FILTER_SIZE]; /* Circular buffer to hold N samples */
uint32_t sum; /* Running sum of all samples */
uint8_t index; /* Current position in the buffer */
} MovingAverageFilter;
uint32_t buffer[AVG_WINDOW];
uint8_t index;
uint32_t sum;
} ADC_Filter;
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
@@ -41,10 +44,6 @@ typedef struct
#define IN_SYNC_BYTE_1 'A'
#define IN_SYNC_BYTE_2 'R'
#define MAX_PWM 63999
#define KP 0.15f /* Start small and increase slowly */
#define DEADBAND_MV 25 /* Ignore errors smaller than 25mV */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
@@ -80,20 +79,54 @@ uint16_t rx_checksum_hold = 0x0000;
uint8_t power_state_value = 0x00;
uint8_t command = 0x00;
uint8_t adc_task_flag = 0x00;
uint16_t vin_adc_val = 0x0000;
uint16_t vout_adc_val = 0x0000;
uint16_t vout_adc_val_av = 0x0000;
uint32_t vdd_ref = 0x00000000;
uint32_t vin_val = 0x00000000;
uint32_t vout_val = 0x00000000;
float vdd_ref = 0;
uint32_t vdd_ref_uint = 0x00000000;
uint32_t v_target = 0x00000000;
uint8_t vset_task_flag = 0x00;
uint8_t serial_number_flag = 0x00;
uint8_t serial_number[19] = "ARRIVE-POWERSIM-001";
uint16_t pwm_value = 0x0000;
uint32_t pwm_value_store = 0x00000000;
uint32_t vout_adc_val = 0x0000000;
uint32_t filtered_adc = 0x0000000;
uint32_t pwm_max = 20000;
float vout = 0;
float vout_adj = 0;
uint32_t vout_adj_uint = 0x00000000;
uint8_t buffer_count = 0x00;
uint32_t v_scale = 0x00000000;
/* Initialise MA filter */
MovingAverageFilter movavFilter;
/* Stored in RAM */
const uint16_t dataBuffer[25] =
{
0x0000,
0x000A,
0x00B5,
0x00C6,
0x00D5,
0x00E3,
0x00F2,
0x0100,
0x010F,
0x011E,
0x012D,
0x013D,
0x014E,
0x0163,
0x017B,
0x0195,
0x01B2,
0x01D0,
0x01F6,
0x021A,
0x0244,
0x0272,
0x02A2,
0x02D8,
0x0311
};
ADC_Filter v_out_filter;
/* USER CODE END PV */
@@ -108,14 +141,12 @@ static void MX_TIM16_Init(void);
/* USER CODE BEGIN PFP */
void power_switch (uint8_t state);
void adc_task(void);
uint32_t get_actual_vdda(ADC_HandleTypeDef *hadc);
float get_actual_vdda(ADC_HandleTypeDef *hadc);
void voltage_conversion_task(void);
void voltage_conversion_task_no_tx(void);
uint32_t get_divider_input_mv(uint32_t raw_adc_value, uint32_t vdda_mv);
void serial_number_task (void);
void MA_Init(MovingAverageFilter *filter);
uint16_t MA_Update(MovingAverageFilter *filter, uint16_t new_sample);
void Control_Loop_Update(uint32_t setpoint_mv, uint32_t measured_mv);
int32_t update_pwm(uint32_t measured_mv);
void ADC_Filter_Init(ADC_Filter *f);
uint32_t ADC_Filter_Update(ADC_Filter *f, uint32_t new_sample);
/* USER CODE END PFP */
@@ -173,34 +204,54 @@ int main(void)
rx_len = 0x00;
rx_len_counter = 0x00;
adc_task_flag = 0x00;
pwm_value = 0x0000;
HAL_UART_Receive_IT(&huart2, rx_hold_buffer, 1);
/* Get real VDDA value */
vdd_ref = get_actual_vdda(&hadc1);
/* Start output PWM at zero */
__HAL_TIM_SET_COMPARE(&htim16, TIM_CHANNEL_1, 0);
HAL_TIM_PWM_Start(&htim16, TIM_CHANNEL_1);
ADC_Filter_Init(&v_out_filter);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
if (adc_task_flag == 0xff)
{
adc_task_flag = 0x00;
if (vset_task_flag != 0xff)
{
adc_task();
vout_adc_val_av = MA_Update (&movavFilter, vout_adc_val);
}
tx_len = 0x04;
voltage_conversion_task();
tx_buffer[0] = IN_SYNC_BYTE_1;
tx_buffer[1] = IN_SYNC_BYTE_2;
tx_buffer[2] = tx_len;
tx_buffer[3] = (uint8_t)((vout_adj_uint >> 24) & 0xFF);
tx_buffer[4] = (uint8_t)((vout_adj_uint >> 16) & 0xFF);
tx_buffer[5] = (uint8_t)((vout_adj_uint >> 8) & 0xFF);
tx_buffer[6] = (uint8_t)(vout_adj_uint & 0xFF);
/* Need to apply checksum to all data bits */
for (tx_len_counter = 0x00; tx_len_counter < tx_len; tx_len_counter++)
{
tx_checksum += tx_buffer[tx_len_counter + 3];
}
tx_checksum = ~tx_checksum;
tx_buffer[7] = (uint8_t)((tx_checksum >> 8) & 0xFF);
tx_buffer[8] = (uint8_t)(tx_checksum & 0xFF);
tx_len = 0x13;
HAL_UART_Transmit(&huart2, tx_buffer, tx_len, 100);
}
if (serial_number_flag == 0xff)
@@ -212,16 +263,29 @@ int main(void)
if (vset_task_flag == 0xff)
{
adc_task();
vout_adc_val_av = MA_Update (&movavFilter, vout_adc_val);
voltage_conversion_task_no_tx();
Control_Loop_Update(v_target, vout_val);
filtered_adc = ADC_Filter_Update(&v_out_filter, vout_adc_val);
vout = ((float)filtered_adc / 4095.0f) * vdd_ref;
vout_adj = vout * 10.9f;
vout_adj_uint = (uint32_t)vout_adj;
pwm_value_store = update_pwm(vout_adj_uint);
pwm_value = (uint16_t)pwm_value_store;
__HAL_TIM_SET_COMPARE(&htim16, TIM_CHANNEL_1, pwm_value);
}
else
{
__HAL_TIM_SET_COMPARE(&htim16, TIM_CHANNEL_1, 0);
}
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
@@ -369,11 +433,11 @@ static void MX_ADC2_Init(void)
hadc2.Init.Resolution = ADC_RESOLUTION_12B;
hadc2.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc2.Init.GainCompensation = 0;
hadc2.Init.ScanConvMode = ADC_SCAN_ENABLE;
hadc2.Init.ScanConvMode = ADC_SCAN_DISABLE;
hadc2.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
hadc2.Init.LowPowerAutoWait = DISABLE;
hadc2.Init.ContinuousConvMode = DISABLE;
hadc2.Init.NbrOfConversion = 2;
hadc2.Init.NbrOfConversion = 1;
hadc2.Init.DiscontinuousConvMode = DISABLE;
hadc2.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc2.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
@@ -397,15 +461,6 @@ static void MX_ADC2_Init(void)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_4;
sConfig.Rank = ADC_REGULAR_RANK_2;
if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN ADC2_Init 2 */
/* USER CODE END ADC2_Init 2 */
@@ -431,9 +486,9 @@ static void MX_TIM2_Init(void)
/* USER CODE END TIM2_Init 1 */
htim2.Instance = TIM2;
htim2.Init.Prescaler = 0;
htim2.Init.Prescaler = 12800-1;
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
htim2.Init.Period = 128999;
htim2.Init.Period = 99;
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
@@ -600,146 +655,104 @@ static void MX_GPIO_Init(void)
}
/* USER CODE BEGIN 4 */
void Control_Loop_Update(uint32_t setpoint_mv, uint32_t measured_mv)
void ADC_Filter_Init(ADC_Filter *f)
{
/* Positive error = need more power */
/* Negative error = need less power */
int32_t error = (int32_t)setpoint_mv - (int32_t)measured_mv;
memset(f->buffer, 0, sizeof(f->buffer));
f->sum = 0;
f->index = 0;
}
if (abs(error) < DEADBAND_MV)
uint32_t ADC_Filter_Update(ADC_Filter *f, uint32_t new_sample)
{
/* Remove the oldest sample from the running sum */
f->sum -= f->buffer[f->index];
/* Store the new sample in the buffer */
f->buffer[f->index] = new_sample;
/* Add the new sample to the sum */
f->sum += new_sample;
/* Move index to next position, wrap around if at end */
f->index++;
if (f->index >= AVG_WINDOW)
{
error = 0; /* Don't change PWM if we are "close enough" */
f->index = 0;
}
/* Proportional Calculation */
float p_term = KP * (float)error;
/* Adjust the Duty Cycle */
static float current_duty = 32000.0f; // Start at 50%
current_duty += p_term;
/* Anti-Windup / Saturation (Crucial for bidirectional) */
/* Prevents the PWM from trying to go to -50% or 200% */
if (current_duty > MAX_PWM) current_duty = (float)MAX_PWM;
if (current_duty < 0.0f) current_duty = 0.0f;
/* Update PWM */
__HAL_TIM_SET_COMPARE(&htim16, TIM_CHANNEL_1, (uint32_t)current_duty);
/* Return the average */
return f->sum / AVG_WINDOW;
}
void MA_Init(MovingAverageFilter *filter)
int32_t update_pwm (uint32_t measured_mv)
{
for (int i = 0; i < FILTER_SIZE; i++)
/* Calculate Error */
int32_t new_pwm = 0;
uint8_t direction_flag = 0x00;
if (v_target >= measured_mv)
{
filter->buffer[i] = 0;
direction_flag = 0x00;
}
filter->sum = 0;
filter->index = 0;
else
{
direction_flag = 0xFF;
}
if (direction_flag == 0xFF)
{
new_pwm = (uint32_t)pwm_value;
new_pwm--;
}
else
{
new_pwm = (uint32_t)pwm_value;
new_pwm++;
}
/* Output Saturation (Keep PWM within hardware limits) */
if (new_pwm > pwm_max)
{
new_pwm = pwm_max;
}
if (new_pwm <= 1)
{
new_pwm = 1;
}
return new_pwm;
}
uint16_t MA_Update(MovingAverageFilter *filter, uint16_t new_sample)
{
/* Subtract the oldest value from the running sum */
filter->sum -= filter->buffer[filter->index];
/* Add the new value to the running sum */
filter->sum += new_sample;
/* Store the new value in the buffer, overwriting the oldest one */
filter->buffer[filter->index] = new_sample;
/* Move the index to the next position (circular buffer wrap-around) */
filter->index++;
filter->index &= (FILTER_SIZE - 1); /* Equivalent to: if (filter->index >= FILTER_SIZE) filter->index = 0; */
/* Calculate the average using bit-shifting (faster than division by power of 2) */
/* For FILTER_SIZE = 16, this is a right shift by 4 bits (sum / 16) */
/* If used 32, it would be sum >> 5 */
return (uint16_t)(filter->sum >> 7);
}
uint32_t get_actual_vdda(ADC_HandleTypeDef *hadc)
float get_actual_vdda(ADC_HandleTypeDef *hadc)
{
uint32_t vrefint_raw = 0;
/* Perform ADC reading of the VREFINT channel */
HAL_ADC_Start(hadc);
if (HAL_ADC_PollForConversion(hadc, 10) == HAL_OK) {
vrefint_raw = HAL_ADC_GetValue(hadc);
if (HAL_ADC_PollForConversion(hadc, 10) == HAL_OK)
{
vrefint_raw = HAL_ADC_GetValue(hadc);
}
HAL_ADC_Stop(hadc);
if (vrefint_raw == 0) return 0; /* Avoid division by zero */
if (vrefint_raw == 0)
{
return 0; /* Avoid division by zero */
}
/* Use the standard ST formula to calculate VDDA */
/* VDDA = VREFINT_CAL_VREF * VREFINT_CAL / VREFINT_DATA */
uint32_t vdda_mv = (VREFINT_CAL_VREF * (uint32_t)(*VREFINT_CAL_ADDR)) / vrefint_raw;
float vdda_mv = (VREFINT_CAL_VREF * (uint32_t)(*VREFINT_CAL_ADDR)) / (float)vrefint_raw;
return vdda_mv;
}
/* Calculate original input voltage from a 22k/2.2k divider in mV */
uint32_t get_divider_input_mv(uint32_t raw_adc_value, uint32_t vdda_mv)
{
/* Calculate the voltage at the ADC pin (Vout of the divider) */
/* Using 64-bit for intermediate to avoid overflow: (Raw * VDDA) / 4095 */
uint64_t vout_mv = ((uint64_t)raw_adc_value * vdda_mv) / 4095;
/* Scale by the divider ratio: (22k + 2.2k) / 2.2k = 11 */
uint32_t vin_mv = (uint32_t)(vout_mv * 10.9);
return vin_mv;
}
/* Voltage Conversion Task */
void voltage_conversion_task(void)
{
/* Get Vin voltage */
vin_val = get_divider_input_mv(vin_adc_val, vdd_ref);
/* Get Vout voltage */
vout_val = get_divider_input_mv(vout_adc_val_av, vdd_ref);
tx_len = 0x08;
tx_buffer[0] = IN_SYNC_BYTE_1;
tx_buffer[1] = IN_SYNC_BYTE_2;
tx_buffer[2] = tx_len;
tx_buffer[3] = (uint8_t)((vin_val >> 24) & 0xFF);
tx_buffer[4] = (uint8_t)((vin_val >> 16) & 0xFF);
tx_buffer[5] = (uint8_t)((vin_val >> 8) & 0xFF);
tx_buffer[6] = (uint8_t)(vin_val & 0xFF);
tx_buffer[7] = (uint8_t)((vout_val >> 24) & 0xFF);
tx_buffer[8] = (uint8_t)((vout_val >> 16) & 0xFF);
tx_buffer[9] = (uint8_t)((vout_val >> 8) & 0xFF);
tx_buffer[10] = (uint8_t)(vout_val & 0xFF);
/* Need to apply checksum to all data bits */
for (tx_len_counter = 0x00; tx_len_counter < tx_len; tx_len_counter++)
{
tx_checksum += tx_buffer[tx_len_counter + 3];
}
tx_checksum = ~tx_checksum;
tx_buffer[11] = (uint8_t)((tx_checksum >> 8) & 0xFF);
tx_buffer[12] = (uint8_t)(tx_checksum & 0xFF);
tx_len = 0x0D;
HAL_UART_Transmit(&huart2, tx_buffer, tx_len, 100);
}
/* Voltage Conversion Task with No UART Tx */
void voltage_conversion_task_no_tx(void)
{
/* Get Vout voltage */
vout_val = get_divider_input_mv(vout_adc_val_av, vdd_ref);
}
void serial_number_task (void)
{
tx_len = 0x13;
@@ -783,11 +796,6 @@ void adc_task (void)
HAL_ADC_Start(&hadc2);
HAL_ADC_PollForConversion(&hadc2, 500);
vout_adc_val = HAL_ADC_GetValue(&hadc2);
HAL_ADC_Start(&hadc2);
HAL_ADC_PollForConversion(&hadc2, 500);
vin_adc_val = HAL_ADC_GetValue(&hadc2);
HAL_ADC_Stop(&hadc2);
}
@@ -798,12 +806,21 @@ void power_switch (uint8_t state)
{
vset_task_flag = 0xFF;
HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_SET);
v_scale = v_target / 1000;
buffer_count = (uint8_t)v_scale;
pwm_value = dataBuffer[buffer_count];
__HAL_TIM_SET_COMPARE(&htim16, TIM_CHANNEL_1, pwm_value);
}
else
{
vset_task_flag = 0x00;
HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
__HAL_TIM_SET_COMPARE(&htim16, TIM_CHANNEL_1, 0);
}
}
@@ -923,7 +940,6 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
case 0x53:
power_state_value = rx_buffer[1];
v_target = ((uint32_t)rx_buffer[2] << 24) | ((uint32_t)rx_buffer[3] << 16) | ((uint32_t)rx_buffer[4] << 8) | ((uint32_t)rx_buffer[5]);
MA_Init(&movavFilter);
power_switch(power_state_value);
break;

View File

@@ -143,12 +143,11 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
__HAL_RCC_GPIOA_CLK_ENABLE();
/**ADC2 GPIO Configuration
PA6 ------> ADC2_IN3
PA7 ------> ADC2_IN4
*/
GPIO_InitStruct.Pin = VIN_Pin|VOUT_Pin;
GPIO_InitStruct.Pin = VOUT_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
HAL_GPIO_Init(VOUT_GPIO_Port, &GPIO_InitStruct);
/* USER CODE BEGIN ADC2_MspInit 1 */
@@ -192,9 +191,8 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
/**ADC2 GPIO Configuration
PA6 ------> ADC2_IN3
PA7 ------> ADC2_IN4
*/
HAL_GPIO_DeInit(GPIOA, VIN_Pin|VOUT_Pin);
HAL_GPIO_DeInit(VOUT_GPIO_Port, VOUT_Pin);
/* USER CODE BEGIN ADC2_MspDeInit 1 */

View File

@@ -1,21 +1,18 @@
../Core/Src/main.c:131:5:main 5
../Core/Src/main.c:237:6:SystemClock_Config 3
../Core/Src/main.c:284:13:MX_ADC1_Init 4
../Core/Src/main.c:352:13:MX_ADC2_Init 4
../Core/Src/main.c:420:13:MX_TIM2_Init 4
../Core/Src/main.c:465:13:MX_TIM16_Init 5
../Core/Src/main.c:528:13:MX_USART2_UART_Init 5
../Core/Src/main.c:576:13:MX_GPIO_Init 1
../Core/Src/main.c:603:6:Control_Loop_Update 5
../Core/Src/main.c:630:6:MA_Init 2
../Core/Src/main.c:641:10:MA_Update 1
../Core/Src/main.c:662:10:get_actual_vdda 3
../Core/Src/main.c:685:10:get_divider_input_mv 1
../Core/Src/main.c:698:6:voltage_conversion_task 2
../Core/Src/main.c:737:6:voltage_conversion_task_no_tx 1
../Core/Src/main.c:743:6:serial_number_task 3
../Core/Src/main.c:781:6:adc_task 1
../Core/Src/main.c:795:6:power_switch 2
../Core/Src/main.c:811:6:HAL_UART_TxCpltCallback 1
../Core/Src/main.c:817:6:HAL_UART_RxCpltCallback 18
../Core/Src/main.c:970:6:Error_Handler 1
../Core/Src/main.c:162:5:main 5
../Core/Src/main.c:301:6:SystemClock_Config 3
../Core/Src/main.c:348:13:MX_ADC1_Init 4
../Core/Src/main.c:416:13:MX_ADC2_Init 3
../Core/Src/main.c:475:13:MX_TIM2_Init 4
../Core/Src/main.c:520:13:MX_TIM16_Init 5
../Core/Src/main.c:583:13:MX_USART2_UART_Init 5
../Core/Src/main.c:631:13:MX_GPIO_Init 1
../Core/Src/main.c:658:6:ADC_Filter_Init 1
../Core/Src/main.c:665:10:ADC_Filter_Update 2
../Core/Src/main.c:688:9:update_pwm 5
../Core/Src/main.c:730:7:get_actual_vdda 3
../Core/Src/main.c:756:6:serial_number_task 3
../Core/Src/main.c:794:6:adc_task 1
../Core/Src/main.c:803:6:power_switch 2
../Core/Src/main.c:828:6:HAL_UART_TxCpltCallback 1
../Core/Src/main.c:834:6:HAL_UART_RxCpltCallback 18
../Core/Src/main.c:986:6:Error_Handler 1

Binary file not shown.

View File

@@ -1,21 +1,18 @@
../Core/Src/main.c:131:5:main 8 static
../Core/Src/main.c:237:6:SystemClock_Config 88 static
../Core/Src/main.c:284:13:MX_ADC1_Init 56 static
../Core/Src/main.c:352:13:MX_ADC2_Init 40 static
../Core/Src/main.c:420:13:MX_TIM2_Init 40 static
../Core/Src/main.c:465:13:MX_TIM16_Init 88 static
../Core/Src/main.c:528:13:MX_USART2_UART_Init 8 static
../Core/Src/main.c:576:13:MX_GPIO_Init 40 static
../Core/Src/main.c:603:6:Control_Loop_Update 24 static
../Core/Src/main.c:630:6:MA_Init 24 static
../Core/Src/main.c:641:10:MA_Update 16 static
../Core/Src/main.c:662:10:get_actual_vdda 24 static
../Core/Src/main.c:685:10:get_divider_input_mv 48 static
../Core/Src/main.c:698:6:voltage_conversion_task 8 static
../Core/Src/main.c:737:6:voltage_conversion_task_no_tx 8 static
../Core/Src/main.c:743:6:serial_number_task 8 static
../Core/Src/main.c:781:6:adc_task 8 static
../Core/Src/main.c:795:6:power_switch 16 static
../Core/Src/main.c:811:6:HAL_UART_TxCpltCallback 16 static
../Core/Src/main.c:817:6:HAL_UART_RxCpltCallback 16 static
../Core/Src/main.c:970:6:Error_Handler 4 static,ignoring_inline_asm
../Core/Src/main.c:162:5:main 8 static
../Core/Src/main.c:301:6:SystemClock_Config 88 static
../Core/Src/main.c:348:13:MX_ADC1_Init 56 static
../Core/Src/main.c:416:13:MX_ADC2_Init 40 static
../Core/Src/main.c:475:13:MX_TIM2_Init 40 static
../Core/Src/main.c:520:13:MX_TIM16_Init 88 static
../Core/Src/main.c:583:13:MX_USART2_UART_Init 8 static
../Core/Src/main.c:631:13:MX_GPIO_Init 40 static
../Core/Src/main.c:658:6:ADC_Filter_Init 16 static
../Core/Src/main.c:665:10:ADC_Filter_Update 16 static
../Core/Src/main.c:688:9:update_pwm 24 static
../Core/Src/main.c:730:7:get_actual_vdda 24 static
../Core/Src/main.c:756:6:serial_number_task 8 static
../Core/Src/main.c:794:6:adc_task 8 static
../Core/Src/main.c:803:6:power_switch 16 static
../Core/Src/main.c:828:6:HAL_UART_TxCpltCallback 16 static
../Core/Src/main.c:834:6:HAL_UART_RxCpltCallback 16 static
../Core/Src/main.c:986:6:Error_Handler 4 static,ignoring_inline_asm

View File

@@ -1,8 +1,8 @@
../Core/Src/stm32g4xx_hal_msp.c:65:6:HAL_MspInit 1
../Core/Src/stm32g4xx_hal_msp.c:94:6:HAL_ADC_MspInit 7
../Core/Src/stm32g4xx_hal_msp.c:166:6:HAL_ADC_MspDeInit 5
../Core/Src/stm32g4xx_hal_msp.c:212:6:HAL_TIM_Base_MspInit 3
../Core/Src/stm32g4xx_hal_msp.c:242:6:HAL_TIM_MspPostInit 2
../Core/Src/stm32g4xx_hal_msp.c:274:6:HAL_TIM_Base_MspDeInit 3
../Core/Src/stm32g4xx_hal_msp.c:310:6:HAL_UART_MspInit 3
../Core/Src/stm32g4xx_hal_msp.c:361:6:HAL_UART_MspDeInit 2
../Core/Src/stm32g4xx_hal_msp.c:165:6:HAL_ADC_MspDeInit 5
../Core/Src/stm32g4xx_hal_msp.c:210:6:HAL_TIM_Base_MspInit 3
../Core/Src/stm32g4xx_hal_msp.c:240:6:HAL_TIM_MspPostInit 2
../Core/Src/stm32g4xx_hal_msp.c:272:6:HAL_TIM_Base_MspDeInit 3
../Core/Src/stm32g4xx_hal_msp.c:308:6:HAL_UART_MspInit 3
../Core/Src/stm32g4xx_hal_msp.c:359:6:HAL_UART_MspDeInit 2

Binary file not shown.

View File

@@ -1,8 +1,8 @@
../Core/Src/stm32g4xx_hal_msp.c:65:6:HAL_MspInit 16 static
../Core/Src/stm32g4xx_hal_msp.c:94:6:HAL_ADC_MspInit 120 static
../Core/Src/stm32g4xx_hal_msp.c:166:6:HAL_ADC_MspDeInit 16 static
../Core/Src/stm32g4xx_hal_msp.c:212:6:HAL_TIM_Base_MspInit 24 static
../Core/Src/stm32g4xx_hal_msp.c:242:6:HAL_TIM_MspPostInit 40 static
../Core/Src/stm32g4xx_hal_msp.c:274:6:HAL_TIM_Base_MspDeInit 16 static
../Core/Src/stm32g4xx_hal_msp.c:310:6:HAL_UART_MspInit 112 static
../Core/Src/stm32g4xx_hal_msp.c:361:6:HAL_UART_MspDeInit 16 static
../Core/Src/stm32g4xx_hal_msp.c:165:6:HAL_ADC_MspDeInit 16 static
../Core/Src/stm32g4xx_hal_msp.c:210:6:HAL_TIM_Base_MspInit 24 static
../Core/Src/stm32g4xx_hal_msp.c:240:6:HAL_TIM_MspPostInit 40 static
../Core/Src/stm32g4xx_hal_msp.c:272:6:HAL_TIM_Base_MspDeInit 16 static
../Core/Src/stm32g4xx_hal_msp.c:308:6:HAL_UART_MspInit 112 static
../Core/Src/stm32g4xx_hal_msp.c:359:6:HAL_UART_MspDeInit 16 static

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -9,19 +9,15 @@ ADC1.Rank-0\#ChannelRegularConversion=1
ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_640CYCLES_5
ADC1.master=1
ADC2.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_3
ADC2.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_4
ADC2.ClockPrescaler=ADC_CLOCK_ASYNC_DIV32
ADC2.CommonPathInternal=null|null|null|null
ADC2.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,NbrOfConversionFlag,ClockPrescaler,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,NbrOfConversion,OversamplingMode,CommonPathInternal
ADC2.NbrOfConversion=2
ADC2.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,NbrOfConversionFlag,ClockPrescaler,NbrOfConversion,OversamplingMode,CommonPathInternal
ADC2.NbrOfConversion=1
ADC2.NbrOfConversionFlag=1
ADC2.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE
ADC2.OffsetNumber-1\#ChannelRegularConversion=ADC_OFFSET_NONE
ADC2.OversamplingMode=DISABLE
ADC2.Rank-0\#ChannelRegularConversion=1
ADC2.Rank-1\#ChannelRegularConversion=2
ADC2.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_640CYCLES_5
ADC2.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_640CYCLES_5
BSP_IP_NAME=NUCLEO-G431KB
CAD.formats=
CAD.pinconfig=
@@ -45,19 +41,18 @@ Mcu.Name=STM32G431K(6-8-B)Tx
Mcu.Package=LQFP32
Mcu.Pin0=PA2
Mcu.Pin1=PA3
Mcu.Pin10=VP_SYS_VS_Systick
Mcu.Pin11=VP_SYS_VS_DBSignals
Mcu.Pin12=VP_TIM2_VS_ClockSourceINT
Mcu.Pin13=VP_TIM16_VS_ClockSourceINT
Mcu.Pin10=VP_SYS_VS_DBSignals
Mcu.Pin11=VP_TIM2_VS_ClockSourceINT
Mcu.Pin12=VP_TIM16_VS_ClockSourceINT
Mcu.Pin2=PA6
Mcu.Pin3=PA7
Mcu.Pin4=PA12
Mcu.Pin5=PA13
Mcu.Pin6=PA14
Mcu.Pin7=PB3
Mcu.Pin8=PB8-BOOT0
Mcu.Pin9=VP_ADC1_Vref_Input
Mcu.PinsNb=14
Mcu.Pin3=PA12
Mcu.Pin4=PA13
Mcu.Pin5=PA14
Mcu.Pin6=PB3
Mcu.Pin7=PB8-BOOT0
Mcu.Pin8=VP_ADC1_Vref_Input
Mcu.Pin9=VP_SYS_VS_Systick
Mcu.PinsNb=13
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32G431KBTx
@@ -99,15 +94,10 @@ PA3.Locked=true
PA3.Mode=Asynchronous
PA3.Signal=USART2_RX
PA6.GPIOParameters=GPIO_Label
PA6.GPIO_Label=VIN
PA6.GPIO_Label=VOUT
PA6.Locked=true
PA6.Mode=IN3-Single-Ended
PA6.Signal=ADC2_IN3
PA7.GPIOParameters=GPIO_Label
PA7.GPIO_Label=VOUT
PA7.Locked=true
PA7.Mode=IN4-Single-Ended
PA7.Signal=ADC2_IN4
PB3.GPIOParameters=GPIO_Label
PB3.GPIO_Label=T_SWO
PB3.Locked=true
@@ -199,8 +189,9 @@ TIM16.Channel=TIM_CHANNEL_1
TIM16.IPParameters=Channel,Prescaler,PeriodNoDither
TIM16.PeriodNoDither=63999
TIM16.Prescaler=1
TIM2.IPParameters=PeriodNoDither
TIM2.PeriodNoDither=128999
TIM2.IPParameters=PeriodNoDither,Prescaler
TIM2.PeriodNoDither=100-1
TIM2.Prescaler=12800-1
USART2.BaudRate=115200
USART2.IPParameters=VirtualMode-Asynchronous,BaudRate
USART2.VirtualMode-Asynchronous=VM_ASYNC