CN
HOMEABOUT USINDUSTRY INFO LORA MODULE INITIALIZATION

LoRa module initialization

By sdga:NiceRF Wireless Technology Co., Ltd

For a better user experience, NiceRF provides you with the initialization code of the LoRa module LoRa1278, hoping to provide help to the majority of users.

 

/** System Clock Configuration

*/

Void SystemClock_Config(void)

{

  RCC_OscInitTypeDef RCC_OscInitStruct;

 

  RCC_ClkInitTypeDef RCC_ClkInitStruct;

 

  RCC_PeriphCLKInitTypeDef PeriphClkInit;

 

/**Configure the main internal regulator output voltage

*/

__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

 

/**Initializes the CPU, AHB and APB busses clocks

*/

 

  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSI; //Select HSI and LSI clock

 

  RCC_OscInitStruct.HSIState = RCC_HSI_ON;  //Open HSI

 

  RCC_OscInitStruct.HSICalibrationValue = 16;  //HSI frequency

 

  RCC_OscInitStruct.LSIState = RCC_LSI_ON;  //Open LSI

 

  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

 

  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;  //The clock source is HSI

 

  RCC_OscInitStruct.PLL.PLLMUL = RCC_PLLMUL_4;  //PLL multiplier

 

  RCC_OscInitStruct.PLL.PLLDIV = RCC_PLLDIV_2;

 

  If (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)  //Initialization, error monitoring

 

  {

 

    Error_Handler();

 

  }

 

 /**Initializes the CPU, AHB and APB busses clocks

 

    */

 

  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK

 

                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;

 

  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // Set the system clock source to HSI

 

  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; //AHB division factor is 1

 

  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; //APB1 division factor is 1

 

  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; //APB2 division factor is 1

 

  If (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)//Configure the clock and set the FLASH delay period at the same time

 

  {

 

    Error_Handler();

 

  }

 

  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART2; // peripheral clock enable

 

  PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;

 

  If (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)

 

  {

 

    Error_Handler();

 

  }

 

  /**Configure the Systick interrupt time

 

    */

 

  HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

 

 /**Configure the Systick

 

    */

 

  HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

 

  /* SysTick_IRQn interrupt configuration */

 

  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

 

}

Contact Us

 +86-755-23080616

 sales@nicerf.com

Website: https://www.nicerf.com/

Address: 309-314, 3/F, Bldg A, Hongdu business building, Zone 43, Baoan Dist, Shenzhen, China

Contact Us
Privacy Policy

Privacy Policy

· Privacy Policy

There is currently no content available


           

Email:sales@nicerf.com

Tel:+86-755-23080616

Address:309-314, 3/F, Bldg A, Hongdu business building, Zone 43, Baoan Dist, Shenzhen, China


×