diff --git a/MX_Generated/Core/Src/main.c b/MX_Generated/Core/Src/main.c index 823e572..733ac63 100644 --- a/MX_Generated/Core/Src/main.c +++ b/MX_Generated/Core/Src/main.c @@ -53,20 +53,20 @@ void SystemClock_Config(void); /* USER CODE BEGIN PFP */ -void SystemClock_Config_MSI2MHz(void); +void SystemClock_Config_FreqDown(void); /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ -void SystemClock_Config_MSI2MHz(void) { +void SystemClock_Config_FreqDown(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI; RCC_OscInitStruct.MSIState = RCC_MSI_ON; - RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_5; + RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_1; RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); diff --git a/src/app_syscalls.c b/src/app_syscalls.c index 53140da..a21665d 100644 --- a/src/app_syscalls.c +++ b/src/app_syscalls.c @@ -4,5 +4,13 @@ int _write(int file, char *ptr, int len) { for (int i = 0; i < len; i++) { ITM_SendChar(ptr[i]); } + + /* ITM and port 0 is enabled*/ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && ((ITM->TER & 1UL) != 0UL)) { + while (ITM->TCR & ITM_TCR_BUSY_Msk) { + /* Wait for ITM not busy (all data sent) */ + } + } + return len; } \ No newline at end of file diff --git a/src/main.c b/src/main.c index 9a10da0..a39e76d 100644 --- a/src/main.c +++ b/src/main.c @@ -22,7 +22,7 @@ #include "app_ranging_impl.h" #include "app_sensors_impl.h" -extern void SystemClock_Config_MSI2MHz(void); +extern void SystemClock_Config_FreqDown(void); extern void SystemClock_Config(void); static app_sensors_impl_t s_dht_impl = { @@ -163,7 +163,7 @@ int main(void) { for (;;) { HAL_SuspendTick(); - SystemClock_Config_MSI2MHz(); + SystemClock_Config_FreqDown(); HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);