Changeset 24 for trunk/fw_g473rct/SES/src/main.c
- Timestamp:
- Aug 31, 2025, 6:56:29 PM (3 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/fw_g473rct/SES/src/main.c
r23 r24 39 39 #include "battery_voltage.h" 40 40 #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" 41 46 /* USER CODE END Includes */ 42 47 … … 61 66 modbus_t modbusData __attribute__((section(".RAM1"))); 62 67 63 __IO uint16_t adc12Data[ 2] __attribute__((section(".RAM1")));68 __IO uint16_t adc12Data[100][2] __attribute__((section(".RAM1"))); 64 69 __IO uint32_t adc1Data[1] __attribute__((section(".RAM1"))); 65 70 __IO uint32_t adc2Data[1] __attribute__((section(".RAM1"))); … … 68 73 __IO uint32_t adc5Data[4] __attribute__((section(".RAM1"))); 69 74 int silentmode =0; 70 static volatile uint32_t newADC1Data = 0; 71 static volatile uint32_t newADC2Data = 0; 75 static volatile uint32_t newADC12Data = 0; 76 static volatile uint32_t newADC3Data = 0; 77 static volatile uint32_t newADC4Data = 0; 78 static volatile uint32_t newADC5Data = 0; 72 79 /* USER CODE END PV */ 73 80 … … 95 102 uint8_t firstStartCatcher; 96 103 int mode_button_disable_time=0; 104 uint32_t adc12_time; 105 uint32_t adc12_lasttime; 97 106 /* USER CODE END 1 */ 98 107 … … 160 169 161 170 // STM32G0 Chiptemperatur Kalibrierung 162 CHIP_TEMPERATURE_Calibration( /*&sys_data*/);171 CHIP_TEMPERATURE_Calibration(); 163 172 164 173 HAL_ADCEx_Calibration_Start(&hadc1, ADC_DIFFERENTIAL_ENDED); … … 169 178 170 179 171 172 180 //SET_BIT(hadc2.Instance->CFGR, ADC_CFGR_DMAEN); //Enable DMA transfer for ADC slave (ADC12_CCR.MDMA = 0b00 -> MDMA mode disabled) 173 181 //HAL_DMA_Start(hadc2.DMA_Handle,(uint32_t)&hadc2.Instance->DR, (uint32_t)adc2Data,1); //Start ADC slave DMA … … 175 183 176 184 //HAL_ADC_Start_DMA(&hadc2, (uint32_t*)adc2Data, 1); 177 if (HAL_ADCEx_MultiModeStart_DMA(&hadc1,(uint32_t *)adc12Data,1 )) //Start ADC interleaved mode185 if (HAL_ADCEx_MultiModeStart_DMA(&hadc1,(uint32_t *)adc12Data,100)) //Start ADC interleaved mode 178 186 { 179 187 /* Start Error */ 180 188 Error_Handler(); 181 189 } 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 182 203 183 204 if (HAL_ADC_Start_DMA(&hadc5, (uint32_t *) adc5Data , 4)) … … 196 217 197 218 /* 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 } 203 251 204 252 if(sys_data.s.parameter.command != 0) … … 327 375 if (hadc->Instance==ADC1) 328 376 { 329 newADC1 Data=1;330 } 331 332 if (hadc->Instance==ADC 2)377 newADC12Data=1; 378 } 379 380 if (hadc->Instance==ADC3) 333 381 { 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; 335 394 } 336 395 }
Note: See TracChangeset
for help on using the changeset viewer.