Ignore:
Timestamp:
Jun 5, 2026, 1:30:00 PM (5 days ago)
Author:
f.jahn
Message:

vor cube code generierung

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/fw_g473rct/Core/Src/main.c

    r70 r71  
    8686/* USER CODE BEGIN PV */
    8787
     88
    8889uint32_t bootLoaderMark __attribute__((section(".no_init")));
    8990
     
    9192
    9293
    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")));
    9596__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")));
    9798__IO uint32_t adc5Data[4];
    98 int silentmode =0;
     99int silentmode = 0;
    99100static volatile uint32_t newADC124Data = 0;
    100101static volatile uint32_t newADC3Data = 0;
     
    119120void DoNothing(void){};
    120121void processUSB(ring_buffer_t* const ring_in_buff, ring_buffer_t* const ring_out_buff);
    121 
     122void ADC2_SetOffset(uint32_t channel, int16_t offset);
    122123/* USER CODE END PFP */
    123124
     
    135136
    136137  /* USER CODE BEGIN 1 */
    137 
    138   CheckRAMHWParity();
     138 
     139  //CheckRAMHWParity();
    139140
    140141  if (bootLoaderMark == GOTO_SYSTEM_BOOTLOADER_MARK)
     
    143144          JumpToBootloader();
    144145  }
    145 
     146 
    146147  uint8_t firstStartCatcher;
    147148  int mode_button_disable_time=0;
     
    161162
    162163  /* USER CODE BEGIN Init */
    163 
     164 
    164165  /* USER CODE END Init */
    165166
     
    170171  printf("System core clock: %uMHz\n", SystemCoreClock / 1000000U);
    171172  /* USER CODE END SysInit */
    172 
     173 
    173174  /* Initialize all configured peripherals */
    174175  MX_GPIO_Init();
     
    186187  MX_CRC_Init();
    187188  MX_RTC_Init();
    188   MX_IWDG_Init();
     189 // MX_IWDG_Init();
    189190  MX_TIM3_Init();
    190191  MX_USB_Device_Init();
     
    192193  /* USER CODE BEGIN 2 */
    193194  printf("Test debug io\r\n");
     195  printf("adc samplerate  core clock: %d kHz\r\n", (uint32_t) GetADCSampleRate() / 1000U);
    194196  SYS_DATA_Init();
    195197  WH_COUNTER_Init();
    196198  AH_COUNTER_Init();
    197 
     199 
    198200  startType_t startType = EEPROM_isFirstStart();
    199201
     
    205207          case FIRST_START_ERROR:                                               EEPROM_fullRestore(&sys_data);            break;
    206208  }
     209 
    207210  HAL_IWDG_Refresh(&hiwdg);
    208211
     
    218221  HAL_IWDG_Refresh(&hiwdg);
    219222  LoadBackupRegister();
    220 
     223 
    221224  // Modbus Initialisierung
    222225  mbInit(&modbusData, sys_data.s.parameter.baudrate, sys_data.s.parameter.parityMode, sys_data.s.parameter.stopBit, &huart2);
    223226  HAL_IWDG_Refresh(&hiwdg);
    224     // STM32G0 Chiptemperatur Kalibrierung
     227  // STM32G0 Chiptemperatur Kalibrierung
    225228  CHIP_TEMPERATURE_Calibration();
    226229
     
    247250  printf("ADS1260 Init\n");
    248251  OUTPUTS_Init();
    249 
     252 
    250253  //Display Adress with Error LED blinks
    251254  for (int n = 0; n < sys_data.s.parameter.slave_address; n++)
     
    260263        HAL_IWDG_Refresh(&hiwdg);
    261264  }
    262 
     265 
    263266  /* USER CODE END 2 */
    264267
    265268  /* USBPD initialisation ---------------------------------*/
    266269  MX_USBPD_Init();
    267 
     270 
    268271  /* Infinite loop */
    269272  /* USER CODE BEGIN WHILE */
     
    274277
    275278    /* USER CODE BEGIN 3 */
    276         HAL_IWDG_Refresh(&hiwdg);
    277         if (newADC124Data == 1)
     279    HAL_IWDG_Refresh(&hiwdg);
     280    if (newADC124Data == 7)
    278281    {
    279282          SHUNT_VOLTAGE_Exec( adc4Data[0]);
     
    287290          newADC124Data = 0;
    288291
     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
    289300          if (HAL_ADC_Start_DMA(&hadc1,(uint32_t*)adc1Data,SAMPLE_ARRAY_SIZE)) Error_Handler(); //Start ADC interleaved mode
    290301          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
    291303        }
    292304
     
    356368      if (silentmode == 0)
    357369      {
    358         HAL_GPIO_TogglePin(LED_FUNCTION_GPIO_Port, LED_FUNCTION_Pin);
     370        //HAL_GPIO_TogglePin(LED_FUNCTION_GPIO_Port, LED_FUNCTION_Pin);
    359371                //HAL_GPIO_TogglePin(AUX_EN_GPIO_Port, AUX_EN_Pin);
    360372      }
     
    379391
    380392      sys_data.s.values.efficiency = EFFICIENCY_Exec();
    381 
    382 #ifdef DEBUG
    383           /*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 #endif
    390393    }
    391394
     
    421424          case COMMAND_SET_RDP_LEVEL1_AND_BOOTSEL:            SetBootFromFlashAndReadOutProtection();                                                                     break;
    422425                  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                                                                                                                       
    424429          default:                                            printf("UNKNOWN COMMAND\n");
    425430        }
     
    799804 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
    800805 {
    801     if (hadc->Instance==ADC1)
     806        if (hadc->Instance==ADC1)
    802807        {
    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)
    807815        {
    808816          newADC3Data=1;
    809817        }
    810 
    811         if (hadc->Instance==ADC5)
     818        else if (hadc->Instance==ADC4)
     819        {
     820          newADC124Data |=4;
     821        }
     822        else if (hadc->Instance==ADC5)
    812823        {
    813824          newADC5Data=1;
     
    10661077        }
    10671078}
     1079
    10681080
    10691081/* USER CODE END 4 */
Note: See TracChangeset for help on using the changeset viewer.