Changeset 71 for trunk/fw_g473rct/Core/Src/main.c
- Timestamp:
- Jun 5, 2026, 1:30:00 PM (5 days ago)
- File:
-
- 1 edited
-
trunk/fw_g473rct/Core/Src/main.c (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/fw_g473rct/Core/Src/main.c
r70 r71 86 86 /* USER CODE BEGIN PV */ 87 87 88 88 89 uint32_t bootLoaderMark __attribute__((section(".no_init"))); 89 90 … … 91 92 92 93 93 __IO uint32_t adc1Data[SAMPLE_ARRAY_SIZE] ;94 __IO uint32_t adc2Data[SAMPLE_ARRAY_SIZE] ;94 __IO uint32_t adc1Data[SAMPLE_ARRAY_SIZE] __attribute__((section(".RAM1_CRC"))); 95 __IO uint32_t adc2Data[SAMPLE_ARRAY_SIZE] __attribute__((section(".RAM1_CRC"))); 95 96 __IO uint32_t adc3Data[3]; 96 __IO uint32_t adc4Data[SAMPLE_ARRAY_SIZE] ;97 __IO uint32_t adc4Data[SAMPLE_ARRAY_SIZE] __attribute__((section(".RAM1_CRC"))); 97 98 __IO uint32_t adc5Data[4]; 98 int silentmode = 0;99 int silentmode = 0; 99 100 static volatile uint32_t newADC124Data = 0; 100 101 static volatile uint32_t newADC3Data = 0; … … 119 120 void DoNothing(void){}; 120 121 void processUSB(ring_buffer_t* const ring_in_buff, ring_buffer_t* const ring_out_buff); 121 122 void ADC2_SetOffset(uint32_t channel, int16_t offset); 122 123 /* USER CODE END PFP */ 123 124 … … 135 136 136 137 /* USER CODE BEGIN 1 */ 137 138 CheckRAMHWParity();138 139 //CheckRAMHWParity(); 139 140 140 141 if (bootLoaderMark == GOTO_SYSTEM_BOOTLOADER_MARK) … … 143 144 JumpToBootloader(); 144 145 } 145 146 146 147 uint8_t firstStartCatcher; 147 148 int mode_button_disable_time=0; … … 161 162 162 163 /* USER CODE BEGIN Init */ 163 164 164 165 /* USER CODE END Init */ 165 166 … … 170 171 printf("System core clock: %uMHz\n", SystemCoreClock / 1000000U); 171 172 /* USER CODE END SysInit */ 172 173 173 174 /* Initialize all configured peripherals */ 174 175 MX_GPIO_Init(); … … 186 187 MX_CRC_Init(); 187 188 MX_RTC_Init(); 188 MX_IWDG_Init();189 // MX_IWDG_Init(); 189 190 MX_TIM3_Init(); 190 191 MX_USB_Device_Init(); … … 192 193 /* USER CODE BEGIN 2 */ 193 194 printf("Test debug io\r\n"); 195 printf("adc samplerate core clock: %d kHz\r\n", (uint32_t) GetADCSampleRate() / 1000U); 194 196 SYS_DATA_Init(); 195 197 WH_COUNTER_Init(); 196 198 AH_COUNTER_Init(); 197 199 198 200 startType_t startType = EEPROM_isFirstStart(); 199 201 … … 205 207 case FIRST_START_ERROR: EEPROM_fullRestore(&sys_data); break; 206 208 } 209 207 210 HAL_IWDG_Refresh(&hiwdg); 208 211 … … 218 221 HAL_IWDG_Refresh(&hiwdg); 219 222 LoadBackupRegister(); 220 223 221 224 // Modbus Initialisierung 222 225 mbInit(&modbusData, sys_data.s.parameter.baudrate, sys_data.s.parameter.parityMode, sys_data.s.parameter.stopBit, &huart2); 223 226 HAL_IWDG_Refresh(&hiwdg); 224 // STM32G0 Chiptemperatur Kalibrierung227 // STM32G0 Chiptemperatur Kalibrierung 225 228 CHIP_TEMPERATURE_Calibration(); 226 229 … … 247 250 printf("ADS1260 Init\n"); 248 251 OUTPUTS_Init(); 249 252 250 253 //Display Adress with Error LED blinks 251 254 for (int n = 0; n < sys_data.s.parameter.slave_address; n++) … … 260 263 HAL_IWDG_Refresh(&hiwdg); 261 264 } 262 265 263 266 /* USER CODE END 2 */ 264 267 265 268 /* USBPD initialisation ---------------------------------*/ 266 269 MX_USBPD_Init(); 267 270 268 271 /* Infinite loop */ 269 272 /* USER CODE BEGIN WHILE */ … … 274 277 275 278 /* USER CODE BEGIN 3 */ 276 HAL_IWDG_Refresh(&hiwdg);277 if (newADC124Data == 1)279 HAL_IWDG_Refresh(&hiwdg); 280 if (newADC124Data == 7) 278 281 { 279 282 SHUNT_VOLTAGE_Exec( adc4Data[0]); … … 287 290 newADC124Data = 0; 288 291 292 //Auskommentiert, bringt komiscxherweise Spannungsschwankungen, beim loggen,... Spannung springt bis zu 50mv 293 // HAL_ADCEx_Calibration_Start(&hadc1, ADC_DIFFERENTIAL_ENDED); 294 // HAL_ADCEx_Calibration_Start(&hadc2, ADC_DIFFERENTIAL_ENDED); 295 // HAL_ADCEx_Calibration_Start(&hadc4, ADC_DIFFERENTIAL_ENDED); 296 297 298 299 289 300 if (HAL_ADC_Start_DMA(&hadc1,(uint32_t*)adc1Data,SAMPLE_ARRAY_SIZE)) Error_Handler(); //Start ADC interleaved mode 290 301 if (HAL_ADC_Start_DMA(&hadc2,(uint32_t*)adc2Data,SAMPLE_ARRAY_SIZE)) Error_Handler(); //Start ADC interleaved mode 302 if (HAL_ADC_Start_DMA(&hadc4,(uint32_t*)adc4Data,SAMPLE_ARRAY_SIZE)) Error_Handler(); //Start ADC interleaved mode 291 303 } 292 304 … … 356 368 if (silentmode == 0) 357 369 { 358 HAL_GPIO_TogglePin(LED_FUNCTION_GPIO_Port, LED_FUNCTION_Pin);370 //HAL_GPIO_TogglePin(LED_FUNCTION_GPIO_Port, LED_FUNCTION_Pin); 359 371 //HAL_GPIO_TogglePin(AUX_EN_GPIO_Port, AUX_EN_Pin); 360 372 } … … 379 391 380 392 sys_data.s.values.efficiency = EFFICIENCY_Exec(); 381 382 #ifdef DEBUG383 /*if (sys_data.s.values.onTime % 5U == 0U)384 {385 static char* Buf = "Hello everybody!\r\n";386 const unsigned BufLen = strlen(Buf);387 CDC_Transmit_FS((uint8_t*)Buf, BufLen - 1);388 }*/389 #endif390 393 } 391 394 … … 421 424 case COMMAND_SET_RDP_LEVEL1_AND_BOOTSEL: SetBootFromFlashAndReadOutProtection(); break; 422 425 case COMMAND_GOTO_SYS_BOOTLOADER: bootLoaderMark = GOTO_SYSTEM_BOOTLOADER_MARK; 423 HAL_NVIC_SystemReset(); 426 HAL_NVIC_SystemReset(); break; 427 case COMMAND_SET_VOLTAGE_MEAS_TO_ZERO: BATTERY_VOLTAGE_ZeroCal(); break; 428 424 429 default: printf("UNKNOWN COMMAND\n"); 425 430 } … … 799 804 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc) 800 805 { 801 if (hadc->Instance==ADC1)806 if (hadc->Instance==ADC1) 802 807 { 803 newADC124Data=1; 804 } 805 806 if (hadc->Instance==ADC3) 808 newADC124Data |= 1; 809 } 810 else if (hadc->Instance == ADC2) 811 { 812 newADC124Data |= 2; 813 } 814 else if (hadc->Instance==ADC3) 807 815 { 808 816 newADC3Data=1; 809 817 } 810 811 if (hadc->Instance==ADC5) 818 else if (hadc->Instance==ADC4) 819 { 820 newADC124Data |=4; 821 } 822 else if (hadc->Instance==ADC5) 812 823 { 813 824 newADC5Data=1; … … 1066 1077 } 1067 1078 } 1079 1068 1080 1069 1081 /* USER CODE END 4 */
Note:
See TracChangeset
for help on using the changeset viewer.
