Fix LPTIM error

This commit is contained in:
NU-LL 2020-05-07 12:39:24 +08:00
parent 6e861d4938
commit c8e7093ee6
5 changed files with 110 additions and 23 deletions

File diff suppressed because one or more lines are too long

View File

@ -20,7 +20,7 @@ SH.ADCx_IN2.0=ADC2_IN2,IN2-Single-Ended
PC10.Signal=SPI3_SCK
PC12.Signal=SPI3_MOSI
RCC.PLLSAI1RoutputFreq_Value=64000000
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART2_UART_Init-USART2-false-HAL-true,4-MX_RTC_Init-RTC-false-HAL-true,5-MX_SPI1_Init-SPI1-false-HAL-true,6-MX_SPI2_Init-SPI2-false-HAL-true,7-MX_SPI3_Init-SPI3-false-HAL-true,8-MX_TIM15_Init-TIM15-false-HAL-true,9-MX_TIM16_Init-TIM16-false-HAL-true,10-MX_TIM17_Init-TIM17-false-HAL-true,11-MX_ADC1_Init-ADC1-false-HAL-true,12-MX_ADC2_Init-ADC2-false-HAL-true,13-MX_ADC3_Init-ADC3-false-HAL-true
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART2_UART_Init-USART2-false-HAL-true,4-MX_RTC_Init-RTC-false-HAL-true,5-MX_SPI1_Init-SPI1-false-HAL-true,6-MX_SPI2_Init-SPI2-false-HAL-true,7-MX_SPI3_Init-SPI3-false-HAL-true,8-MX_TIM15_Init-TIM15-false-HAL-true,9-MX_TIM16_Init-TIM16-false-HAL-true,10-MX_TIM17_Init-TIM17-false-HAL-true,11-MX_ADC1_Init-ADC1-false-HAL-true,12-MX_ADC2_Init-ADC2-false-HAL-true,13-MX_ADC3_Init-ADC3-false-HAL-true,14-MX_LPTIM1_Init-LPTIM1-false-HAL-true
VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled
RCC.RTCFreq_Value=32768
RCC.USART2Freq_Value=80000000
@ -34,12 +34,12 @@ PC14-OSC32_IN\ (PC14).Mode=LSE-External-Oscillator
PA14\ (JTCK-SWCLK).Signal=SYS_JTCK-SWCLK
RCC.I2C3Freq_Value=80000000
RCC.LPTIM1Freq_Value=80000000
Mcu.IP4=RCC
Mcu.IP4=NVIC
Mcu.IP5=RCC
RCC.FCLKCortexFreq_Value=80000000
Mcu.IP5=RTC
Mcu.IP2=ADC3
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false
Mcu.IP3=NVIC
Mcu.IP3=LPTIM1
Mcu.IP0=ADC1
Mcu.IP1=ADC2
Mcu.UserConstants=
@ -49,7 +49,7 @@ Mcu.ThirdPartyNb=0
SPI1.Direction=SPI_DIRECTION_2LINES
RCC.HCLKFreq_Value=80000000
SH.ADCx_IN3.0=ADC3_IN3,IN3-Single-Ended
Mcu.IPNb=14
Mcu.IPNb=15
ProjectManager.PreviousToolchain=
RCC.APB2TimFreq_Value=80000000
SPI1.CalculateBaudRate=40.0 MBits/s
@ -73,15 +73,16 @@ ProjectManager.ProjectBuild=false
RCC.HSE_VALUE=8000000
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false
Mcu.IP10=TIM15
Mcu.IP10=SYS
USART2.VirtualMode-Asynchronous=VM_ASYNC
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true
RCC.RTCClockSelection=RCC_RTCCLKSOURCE_LSE
Mcu.IP12=TIM17
Mcu.IP11=TIM16
Mcu.IP12=TIM16
Mcu.IP11=TIM15
ProjectManager.FirmwarePackage=STM32Cube FW_L4 V1.15.1
MxDb.Version=DB.5.0.60
Mcu.IP13=USART2
Mcu.IP14=USART2
Mcu.IP13=TIM17
ProjectManager.BackupPrevious=false
RCC.VCOInputFreq_Value=16000000
SH.ADCx_IN1.ConfNb=1
@ -102,6 +103,7 @@ SPI3.Mode=SPI_MODE_MASTER
ProjectManager.ToolChainLocation=
RCC.LSI_VALUE=32000
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
VP_LPTIM1_VS_LPTIM_counterModeInternalClock.Mode=Counts__internal_clock_event_00
ADC3.Rank-0\#ChannelRegularConversion=1
RCC.LSCOPinFreq_Value=32000
ADC2.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_2CYCLES_5
@ -128,7 +130,7 @@ RCC.PLLQoutputFreq_Value=80000000
ProjectManager.ProjectFileName=CubeMX_Config.ioc
ADC1.Rank-0\#ChannelRegularConversion=1
PA7.Mode=Full_Duplex_Master
Mcu.PinsNb=23
Mcu.PinsNb=24
ProjectManager.NoMain=false
SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate
ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,NbrOfConversionFlag,master
@ -183,17 +185,18 @@ Mcu.Name=STM32L476R(C-E-G)Tx
RCC.LPTIM2Freq_Value=80000000
PA2.Signal=USART2_TX
ProjectManager.UnderRoot=false
Mcu.IP8=SPI3
Mcu.IP9=SYS
Mcu.IP6=SPI1
Mcu.IP7=SPI2
Mcu.IP8=SPI2
Mcu.IP9=SPI3
Mcu.IP6=RTC
Mcu.IP7=SPI1
ProjectManager.CoupleFile=false
PA13\ (JTMS-SWDIO).Mode=Serial_Wire
RCC.SYSCLKFreq_VALUE=80000000
Mcu.Pin22=VP_TIM17_VS_ClockSourceINT
Mcu.Pin20=VP_TIM15_VS_ClockSourceINT
Mcu.Pin22=VP_TIM16_VS_ClockSourceINT
Mcu.Pin23=VP_TIM17_VS_ClockSourceINT
Mcu.Pin20=VP_SYS_VS_Systick
ADC1.master=1
Mcu.Pin21=VP_TIM16_VS_ClockSourceINT
Mcu.Pin21=VP_TIM15_VS_ClockSourceINT
ADC2.NbrOfConversionFlag=1
RCC.PLLSAI2PoutputFreq_Value=18285714.285714287
NVIC.ForceEnableDMAVector=true
@ -208,11 +211,11 @@ NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
Mcu.Pin16=PC11
Mcu.Pin13=PA13 (JTMS-SWDIO)
Mcu.Pin14=PA14 (JTCK-SWCLK)
Mcu.Pin19=VP_SYS_VS_Systick
Mcu.Pin19=VP_RTC_VS_RTC_Activate
ProjectManager.ComputerToolchain=false
Mcu.Pin17=PC12
RCC.HSI_VALUE=16000000
Mcu.Pin18=VP_RTC_VS_RTC_Activate
Mcu.Pin18=VP_LPTIM1_VS_LPTIM_counterModeInternalClock
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
ADC1.NbrOfConversionFlag=1
Mcu.Pin11=PB10
@ -220,6 +223,7 @@ Mcu.Pin12=PB14
RCC.PLLN=10
Mcu.Pin10=PA7
PA2.Mode=Asynchronous
VP_LPTIM1_VS_LPTIM_counterModeInternalClock.Signal=LPTIM1_VS_LPTIM_counterModeInternalClock
RCC.PWRFreq_Value=80000000
RCC.I2C2Freq_Value=80000000
RCC.APB1Freq_Value=80000000

View File

@ -69,7 +69,7 @@
/*#define HAL_IWDG_MODULE_ENABLED */
/*#define HAL_LTDC_MODULE_ENABLED */
/*#define HAL_LCD_MODULE_ENABLED */
/*#define HAL_LPTIM_MODULE_ENABLED */
#define HAL_LPTIM_MODULE_ENABLED
/*#define HAL_MMC_MODULE_ENABLED */
/*#define HAL_NAND_MODULE_ENABLED */
/*#define HAL_NOR_MODULE_ENABLED */

View File

@ -66,6 +66,8 @@ ADC_HandleTypeDef hadc1;
ADC_HandleTypeDef hadc2;
ADC_HandleTypeDef hadc3;
LPTIM_HandleTypeDef hlptim1;
RTC_HandleTypeDef hrtc;
SPI_HandleTypeDef hspi1;
@ -97,6 +99,7 @@ static void MX_TIM17_Init(void);
static void MX_ADC1_Init(void);
static void MX_ADC2_Init(void);
static void MX_ADC3_Init(void);
static void MX_LPTIM1_Init(void);
/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
@ -146,6 +149,7 @@ int main(void)
MX_ADC1_Init();
MX_ADC2_Init();
MX_ADC3_Init();
MX_LPTIM1_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
@ -208,8 +212,9 @@ void SystemClock_Config(void)
Error_Handler();
}
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC|RCC_PERIPHCLK_USART2
|RCC_PERIPHCLK_ADC;
|RCC_PERIPHCLK_LPTIM1|RCC_PERIPHCLK_ADC;
PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;
PeriphClkInit.Lptim1ClockSelection = RCC_LPTIM1CLKSOURCE_PCLK;
PeriphClkInit.AdcClockSelection = RCC_ADCCLKSOURCE_PLLSAI1;
PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_HSI;
@ -410,6 +415,40 @@ static void MX_ADC3_Init(void)
}
/**
* @brief LPTIM1 Initialization Function
* @param None
* @retval None
*/
static void MX_LPTIM1_Init(void)
{
/* USER CODE BEGIN LPTIM1_Init 0 */
/* USER CODE END LPTIM1_Init 0 */
/* USER CODE BEGIN LPTIM1_Init 1 */
/* USER CODE END LPTIM1_Init 1 */
hlptim1.Instance = LPTIM1;
hlptim1.Init.Clock.Source = LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC;
hlptim1.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV1;
hlptim1.Init.Trigger.Source = LPTIM_TRIGSOURCE_SOFTWARE;
hlptim1.Init.OutputPolarity = LPTIM_OUTPUTPOLARITY_HIGH;
hlptim1.Init.UpdateMode = LPTIM_UPDATE_IMMEDIATE;
hlptim1.Init.CounterSource = LPTIM_COUNTERSOURCE_INTERNAL;
hlptim1.Init.Input1Source = LPTIM_INPUT1SOURCE_GPIO;
hlptim1.Init.Input2Source = LPTIM_INPUT2SOURCE_GPIO;
if (HAL_LPTIM_Init(&hlptim1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN LPTIM1_Init 2 */
/* USER CODE END LPTIM1_Init 2 */
}
/**
* @brief RTC Initialization Function
* @param None

View File

@ -254,6 +254,50 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
}
/**
* @brief LPTIM MSP Initialization
* This function configures the hardware resources used in this example
* @param hlptim: LPTIM handle pointer
* @retval None
*/
void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef* hlptim)
{
if(hlptim->Instance==LPTIM1)
{
/* USER CODE BEGIN LPTIM1_MspInit 0 */
/* USER CODE END LPTIM1_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_LPTIM1_CLK_ENABLE();
/* USER CODE BEGIN LPTIM1_MspInit 1 */
/* USER CODE END LPTIM1_MspInit 1 */
}
}
/**
* @brief LPTIM MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param hlptim: LPTIM handle pointer
* @retval None
*/
void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef* hlptim)
{
if(hlptim->Instance==LPTIM1)
{
/* USER CODE BEGIN LPTIM1_MspDeInit 0 */
/* USER CODE END LPTIM1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_LPTIM1_CLK_DISABLE();
/* USER CODE BEGIN LPTIM1_MspDeInit 1 */
/* USER CODE END LPTIM1_MspDeInit 1 */
}
}
/**
* @brief RTC MSP Initialization
* This function configures the hardware resources used in this example