Ignore:
Timestamp:
Aug 31, 2025, 6:56:29 PM (3 days ago)
Author:
f.jahn
Message:

Shunt Temperatursensor aktiviert

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/fw_g473rct/SES/src/main.c

    r23 r24  
    3939#include "battery_voltage.h"
    4040#include "ads1260.h"
     41#include "shunt_voltage.h"
     42#include "fast_current.h"
     43#include "int_bat_voltage.h"
     44#include "chip_temperature.h"
     45#include "shunt_temperature.h"
    4146/* USER CODE END Includes */
    4247
     
    6166modbus_t modbusData __attribute__((section(".RAM1")));
    6267
    63 __IO uint16_t adc12Data[2] __attribute__((section(".RAM1")));
     68__IO uint16_t adc12Data[100][2] __attribute__((section(".RAM1")));
    6469__IO uint32_t adc1Data[1] __attribute__((section(".RAM1")));
    6570__IO uint32_t adc2Data[1] __attribute__((section(".RAM1")));
     
    6873__IO uint32_t adc5Data[4] __attribute__((section(".RAM1")));
    6974int silentmode =0;
    70 static volatile uint32_t newADC1Data = 0;
    71 static volatile uint32_t newADC2Data = 0;
     75static volatile uint32_t newADC12Data = 0;
     76static volatile uint32_t newADC3Data = 0;
     77static volatile uint32_t newADC4Data = 0;
     78static volatile uint32_t newADC5Data = 0;
    7279/* USER CODE END PV */
    7380
     
    95102    uint8_t firstStartCatcher;
    96103        int mode_button_disable_time=0;
     104        uint32_t adc12_time;
     105        uint32_t adc12_lasttime;
    97106  /* USER CODE END 1 */
    98107
     
    160169
    161170    // STM32G0 Chiptemperatur Kalibrierung
    162   CHIP_TEMPERATURE_Calibration(/*&sys_data*/);
     171  CHIP_TEMPERATURE_Calibration();
    163172
    164173  HAL_ADCEx_Calibration_Start(&hadc1, ADC_DIFFERENTIAL_ENDED);
     
    169178
    170179
    171 
    172180  //SET_BIT(hadc2.Instance->CFGR, ADC_CFGR_DMAEN); //Enable DMA transfer for ADC slave (ADC12_CCR.MDMA = 0b00 -> MDMA mode disabled)
    173181  //HAL_DMA_Start(hadc2.DMA_Handle,(uint32_t)&hadc2.Instance->DR, (uint32_t)adc2Data,1); //Start ADC slave DMA
     
    175183 
    176184    //HAL_ADC_Start_DMA(&hadc2, (uint32_t*)adc2Data, 1);
    177   if (HAL_ADCEx_MultiModeStart_DMA(&hadc1,(uint32_t *)adc12Data,1))  //Start ADC interleaved mode
     185  if (HAL_ADCEx_MultiModeStart_DMA(&hadc1,(uint32_t *)adc12Data,100))  //Start ADC interleaved mode
    178186  {
    179187     /* Start Error */
    180188     Error_Handler();
    181189  }
     190
     191  if (HAL_ADC_Start_DMA(&hadc3, (uint32_t *) adc3Data , 3))
     192  {
     193     /* Start Error */
     194     Error_Handler();
     195  }
     196
     197  if (HAL_ADC_Start_DMA(&hadc4, (uint32_t *) adc4Data , 1))
     198  {
     199     /* Start Error */
     200     Error_Handler();
     201  }
     202
    182203
    183204  if (HAL_ADC_Start_DMA(&hadc5, (uint32_t *) adc5Data , 4))
     
    196217
    197218    /* USER CODE BEGIN 3 */
    198         if (newADC1Data == 1)
    199     {
    200           BATTERY_VOLTAGE_Exec( adc12Data[1]);
    201         }
    202 
     219        if (newADC12Data == 1)
     220    {
     221          //Mit ADC_DIV2,Sample time 12,5Cycklen, ADC Clock 50Mhz, Oversampling 256
     222          //Tconv = 6400 Takte = 0,128ms Pro Konvertierung. Also für 100 messwerte 12,8mS
     223          BATTERY_VOLTAGE_Exec( adc12Data[0][1]);
     224          FAST_CURRENT_Exec(adc12Data[0][0]);
     225          newADC12Data = 0;
     226          adc12_time = HAL_GetTick() - adc12_lasttime;
     227          adc12_lasttime = HAL_GetTick();
     228
     229        }
     230
     231
     232        if (newADC3Data == 1)
     233    {
     234          SHUNT_TEMPERATURE_Exec(adc3Data[0]);
     235        }
     236
     237
     238        if (newADC4Data == 1)
     239    {
     240          SHUNT_VOLTAGE_Exec( adc4Data[0]);
     241        }
     242
     243
     244        if (newADC5Data == 1)
     245    {
     246          CHIP_TEMPERATURE_Exec(adc5Data[0]);
     247          INT_BAT_VOLTAGE_Exec( adc5Data[1]);
     248          sys_data.s.values.ovp_sense =  (adc5Data[2] * VREF * 21 ) / 65536.0;
     249      sys_data.s.values.lvp_sense =  (adc5Data[3] * VREF * 21 ) / 65536.0;
     250        }
    203251
    204252        if(sys_data.s.parameter.command != 0)
     
    327375    if (hadc->Instance==ADC1)
    328376        {
    329           newADC1Data=1;
    330         }
    331 
    332         if (hadc->Instance==ADC2)
     377          newADC12Data=1;
     378        }
     379
     380        if (hadc->Instance==ADC3)
    333381        {
    334           newADC2Data=1;
     382          newADC3Data=1;
     383        }
     384
     385
     386        if (hadc->Instance==ADC4)
     387        {
     388          newADC4Data=1;
     389        }
     390
     391        if (hadc->Instance==ADC5)
     392        {
     393          newADC5Data=1;
    335394        }
    336395 }
Note: See TracChangeset for help on using the changeset viewer.