cancel
Showing results for 
Search instead for 
Did you mean: 

How to make B-L072Z-LRWAN1 work at 4.2MHz

hirot
Associate

B-L072Z-LRWAN1" and "STM32CubeExpansion LRWAN V2.1.0" are used to transmit sensor data over LoRaWAN.


The default CPU clock is 32 MHz.
I want to set the CPU clock to 4.2 MHz to save power.

I set up SystemClock_Config() as follows, but when I use it in OTAA, it sends a JOIN request, but does not seem to proceed to further processing.

Could this be an RTC problem? How can I make it work at 4.2MHz?

void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

/* MSI configuration and activation */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6; // MSI = 4.194 MHz
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // PLL is not used

if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}

/* Select MSI as system clock source and configure the HCLK, PCLK1 and PCLK2
clocks dividers to not divide the system clock */
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
{
Error_Handler();
}
}

1 REPLY 1
hirot
Associate

It seems that the RTC is used for interrupting receiving.

For 4.2 MHz, I am thinking I need to use MSI without using RTC, so how should I do the receive interrupts?