fix double freq issue and play around with resolution
This commit is contained in:
parent
f12f95c565
commit
2b9287bc21
@ -5,7 +5,7 @@ SourcePath=/home/wn/workspace-stm32/inverter2/cubemx/output/inverter2/Src
|
||||
SourceFiles=stm32f1xx_it.h;stm32f1xx_hal_conf.h;mxconstants.h;stm32f1xx_it.c;stm32f1xx_hal_msp.c;main.c;
|
||||
|
||||
[PreviousLibFiles]
|
||||
LibFiles=Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_can.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_can_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rtc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rtc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rtc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rtc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Drivers/CMSIS/Include/cmsis_armcc_V6.h;Drivers/CMSIS/Include/core_cmFunc.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/core_cmInstr.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/arm_math.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/core_cmSimd.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103x6.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xg.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f102xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101x6.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f107xc.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f102x6.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xe.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xg.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xe.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f100xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f100xe.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f105xc.h;
|
||||
LibFiles=Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_can.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_can_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rtc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rtc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rtc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rtc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Drivers/CMSIS/Include/cmsis_armcc_V6.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cmSimd.h;Drivers/CMSIS/Include/core_cmFunc.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/arm_math.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cmInstr.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f100xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101x6.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f102xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xg.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f102x6.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f105xc.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f100xe.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xe.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xg.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f107xc.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xe.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f101xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103x6.h;
|
||||
|
||||
[PreviousUsedRideFiles]
|
||||
SourceFiles=../Src/main.c;../Src/stm32f1xx_it.c;../Src/stm32f1xx_hal_msp.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rtc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rtc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;../Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xe.s;
|
||||
|
@ -208,21 +208,21 @@ static void MX_RTC_Init(void)
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
sTime.Hours = 1;
|
||||
sTime.Minutes = 0;
|
||||
sTime.Seconds = 0;
|
||||
sTime.Hours = 0x1;
|
||||
sTime.Minutes = 0x0;
|
||||
sTime.Seconds = 0x0;
|
||||
|
||||
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK)
|
||||
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
DateToUpdate.WeekDay = RTC_WEEKDAY_MONDAY;
|
||||
DateToUpdate.Month = RTC_MONTH_JANUARY;
|
||||
DateToUpdate.Date = 1;
|
||||
DateToUpdate.Year = 0;
|
||||
DateToUpdate.Date = 0x1;
|
||||
DateToUpdate.Year = 0x0;
|
||||
|
||||
if (HAL_RTC_SetDate(&hrtc, &DateToUpdate, RTC_FORMAT_BIN) != HAL_OK)
|
||||
if (HAL_RTC_SetDate(&hrtc, &DateToUpdate, RTC_FORMAT_BCD) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
@ -237,7 +237,7 @@ static void MX_TIM1_Init(void)
|
||||
TIM_MasterConfigTypeDef sMasterConfig;
|
||||
|
||||
htim1.Instance = TIM1;
|
||||
htim1.Init.Prescaler = 72;
|
||||
htim1.Init.Prescaler = 36;
|
||||
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim1.Init.Period = 5000;
|
||||
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
@ -271,7 +271,7 @@ static void MX_TIM2_Init(void)
|
||||
TIM_OC_InitTypeDef sConfigOC;
|
||||
|
||||
htim2.Instance = TIM2;
|
||||
htim2.Init.Prescaler = 72;
|
||||
htim2.Init.Prescaler = 36;
|
||||
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim2.Init.Period = 5000;
|
||||
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
@ -320,7 +320,7 @@ static void MX_TIM4_Init(void)
|
||||
TIM_OC_InitTypeDef sConfigOC;
|
||||
|
||||
htim4.Instance = TIM4;
|
||||
htim4.Init.Prescaler = 72;
|
||||
htim4.Init.Prescaler = 36;
|
||||
htim4.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim4.Init.Period = 5000;
|
||||
htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
@ -369,7 +369,7 @@ static void MX_TIM5_Init(void)
|
||||
TIM_OC_InitTypeDef sConfigOC;
|
||||
|
||||
htim5.Instance = TIM5;
|
||||
htim5.Init.Prescaler = 72;
|
||||
htim5.Init.Prescaler = 36;
|
||||
htim5.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim5.Init.Period = 5000;
|
||||
htim5.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
|
@ -3,27 +3,27 @@ CAN.CalculateTimeBit=1333
|
||||
CAN.CalculateTimeQuantum=444.44444444444446
|
||||
CAN.IPParameters=CalculateTimeQuantum,CalculateTimeBit
|
||||
Dma.Request0=TIM5_CH2
|
||||
Dma.Request1=TIM4_CH1
|
||||
Dma.Request2=TIM2_CH1
|
||||
Dma.Request1=TIM2_CH1
|
||||
Dma.Request2=TIM4_CH1
|
||||
Dma.RequestsNb=3
|
||||
Dma.TIM2_CH1.2.Direction=DMA_MEMORY_TO_PERIPH
|
||||
Dma.TIM2_CH1.2.Instance=DMA1_Channel5
|
||||
Dma.TIM2_CH1.2.MemDataAlignment=DMA_MDATAALIGN_HALFWORD
|
||||
Dma.TIM2_CH1.2.MemInc=DMA_MINC_ENABLE
|
||||
Dma.TIM2_CH1.2.Mode=DMA_CIRCULAR
|
||||
Dma.TIM2_CH1.2.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD
|
||||
Dma.TIM2_CH1.2.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.TIM2_CH1.2.Priority=DMA_PRIORITY_LOW
|
||||
Dma.TIM2_CH1.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
|
||||
Dma.TIM4_CH1.1.Direction=DMA_MEMORY_TO_PERIPH
|
||||
Dma.TIM4_CH1.1.Instance=DMA1_Channel1
|
||||
Dma.TIM4_CH1.1.MemDataAlignment=DMA_MDATAALIGN_HALFWORD
|
||||
Dma.TIM4_CH1.1.MemInc=DMA_MINC_ENABLE
|
||||
Dma.TIM4_CH1.1.Mode=DMA_CIRCULAR
|
||||
Dma.TIM4_CH1.1.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD
|
||||
Dma.TIM4_CH1.1.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.TIM4_CH1.1.Priority=DMA_PRIORITY_LOW
|
||||
Dma.TIM4_CH1.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
|
||||
Dma.TIM2_CH1.1.Direction=DMA_MEMORY_TO_PERIPH
|
||||
Dma.TIM2_CH1.1.Instance=DMA1_Channel5
|
||||
Dma.TIM2_CH1.1.MemDataAlignment=DMA_MDATAALIGN_HALFWORD
|
||||
Dma.TIM2_CH1.1.MemInc=DMA_MINC_ENABLE
|
||||
Dma.TIM2_CH1.1.Mode=DMA_CIRCULAR
|
||||
Dma.TIM2_CH1.1.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD
|
||||
Dma.TIM2_CH1.1.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.TIM2_CH1.1.Priority=DMA_PRIORITY_LOW
|
||||
Dma.TIM2_CH1.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
|
||||
Dma.TIM4_CH1.2.Direction=DMA_MEMORY_TO_PERIPH
|
||||
Dma.TIM4_CH1.2.Instance=DMA1_Channel1
|
||||
Dma.TIM4_CH1.2.MemDataAlignment=DMA_MDATAALIGN_HALFWORD
|
||||
Dma.TIM4_CH1.2.MemInc=DMA_MINC_ENABLE
|
||||
Dma.TIM4_CH1.2.Mode=DMA_CIRCULAR
|
||||
Dma.TIM4_CH1.2.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD
|
||||
Dma.TIM4_CH1.2.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.TIM4_CH1.2.Priority=DMA_PRIORITY_LOW
|
||||
Dma.TIM4_CH1.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
|
||||
Dma.TIM5_CH2.0.Direction=DMA_MEMORY_TO_PERIPH
|
||||
Dma.TIM5_CH2.0.Instance=DMA2_Channel4
|
||||
Dma.TIM5_CH2.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD
|
||||
@ -193,12 +193,13 @@ RCC.HCLKFreq_Value=72000000
|
||||
RCC.HSIState=RCC_HSI_ON
|
||||
RCC.I2S2Freq_Value=72000000
|
||||
RCC.I2S3Freq_Value=72000000
|
||||
RCC.IPParameters=ADCFreqValue,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,FCLKCortexFreq_Value,FSMCFreq_Value,FamilyName,HCLKFreq_Value,HSIState,I2S2Freq_Value,I2S3Freq_Value,MCOFreq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,PLLMUL,PLLSourceVirtual,SDIOFreq_Value,SDIOHCLKDiv2FreqValue,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,USBFreq_Value,VCOOutput2Freq_Value
|
||||
RCC.MCOFreq_Value=72000000
|
||||
RCC.IPParameters=ADCFreqValue,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,FCLKCortexFreq_Value,FSMCFreq_Value,FamilyName,HCLKFreq_Value,HSIState,I2S2Freq_Value,I2S3Freq_Value,MCOFreq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,PLLMUL,PLLSourceVirtual,RCC_MCOSource,SDIOFreq_Value,SDIOHCLKDiv2FreqValue,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,USBFreq_Value,VCOOutput2Freq_Value
|
||||
RCC.MCOFreq_Value=36000000
|
||||
RCC.PLLCLKFreq_Value=72000000
|
||||
RCC.PLLMCOFreq_Value=36000000
|
||||
RCC.PLLMUL=RCC_PLL_MUL9
|
||||
RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE
|
||||
RCC.RCC_MCOSource=RCC_MCO1SOURCE_PLLCLK
|
||||
RCC.SDIOFreq_Value=72000000
|
||||
RCC.SDIOHCLKDiv2FreqValue=36000000
|
||||
RCC.SYSCLKFreq_VALUE=72000000
|
||||
@ -206,8 +207,6 @@ RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
|
||||
RCC.TimSysFreq_Value=72000000
|
||||
RCC.USBFreq_Value=72000000
|
||||
RCC.VCOOutput2Freq_Value=8000000
|
||||
RTC.Format=RTC_FORMAT_BIN
|
||||
RTC.IPParameters=Format
|
||||
SH.S_TIM2_CH1_ETR.0=TIM2_CH1,PWM Generation1 CH1
|
||||
SH.S_TIM2_CH1_ETR.ConfNb=1
|
||||
SH.S_TIM4_CH1.0=TIM4_CH1,PWM Generation1 CH1
|
||||
@ -216,23 +215,23 @@ SH.S_TIM5_CH2.0=TIM5_CH2,PWM Generation2 CH2
|
||||
SH.S_TIM5_CH2.ConfNb=1
|
||||
TIM1.IPParameters=TIM_MasterOutputTrigger,TIM_MasterSlaveMode,Prescaler,Period
|
||||
TIM1.Period=5000
|
||||
TIM1.Prescaler=72
|
||||
TIM1.Prescaler=36
|
||||
TIM1.TIM_MasterOutputTrigger=TIM_TRGO_RESET
|
||||
TIM1.TIM_MasterSlaveMode=TIM_MASTERSLAVEMODE_DISABLE
|
||||
TIM2.IPParameters=Prescaler,Period,Pulse-PWM Generation1 CH1,OCPolarity_1
|
||||
TIM2.OCPolarity_1=TIM_OCPOLARITY_LOW
|
||||
TIM2.Period=5000
|
||||
TIM2.Prescaler=72
|
||||
TIM2.Prescaler=36
|
||||
TIM2.Pulse-PWM\ Generation1\ CH1=1000
|
||||
TIM4.IPParameters=Prescaler,Period,OCPolarity_1
|
||||
TIM4.OCPolarity_1=TIM_OCPOLARITY_LOW
|
||||
TIM4.Period=5000
|
||||
TIM4.Prescaler=72
|
||||
TIM4.Prescaler=36
|
||||
TIM5.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
|
||||
TIM5.IPParameters=Channel-PWM Generation2 CH2,Prescaler,Period,OCPolarity_2
|
||||
TIM5.OCPolarity_2=TIM_OCPOLARITY_LOW
|
||||
TIM5.Period=5000
|
||||
TIM5.Prescaler=72
|
||||
TIM5.Prescaler=36
|
||||
VP_RTC_No_RTC_Output.Mode=RTC_OUT_NO
|
||||
VP_RTC_No_RTC_Output.Signal=RTC_No_RTC_Output
|
||||
VP_SYS_VS_Systick.Mode=SysTick
|
||||
|
BIN
doc/freqInCalc.xlsx
Normal file
BIN
doc/freqInCalc.xlsx
Normal file
Binary file not shown.
@ -6,6 +6,10 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifdef SEMIHOSTING_ENABLED
|
||||
#include <diag/Trace.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
@ -20,8 +24,8 @@ extern TIM_HandleTypeDef htim4;
|
||||
extern TIM_HandleTypeDef htim5;
|
||||
|
||||
|
||||
#define NUM_OF_SINE_SLOT 30
|
||||
const uint32_t FREQ_IN = 1E6;
|
||||
#define NUM_OF_SINE_SLOT 60
|
||||
const uint32_t FREQ_IN = 2E6;
|
||||
const float PI = 3.14159;
|
||||
float slotAngle = 180.0 / NUM_OF_SINE_SLOT;
|
||||
float sineValues[NUM_OF_SINE_SLOT];
|
||||
@ -87,7 +91,12 @@ void inverterBegin() {
|
||||
void inverterStart(uint8_t freqOut, direction_t direction) {
|
||||
inverterStop();
|
||||
|
||||
uint16_t slotWidth = (FREQ_IN / (freqOut * NUM_OF_SINE_SLOT * 4));
|
||||
uint16_t slotWidth = (FREQ_IN / (freqOut * NUM_OF_SINE_SLOT * 2));
|
||||
|
||||
#ifdef SEMIHOSTING_ENABLE
|
||||
trace_printf("slotWidth: %d\n", slotWidth);
|
||||
#endif
|
||||
|
||||
for (uint8_t i = 0; i < NUM_OF_SINE_SLOT; i++) {
|
||||
IV[i] = (uint16_t)(sineValues[i] * 0.9 * slotWidth);
|
||||
}
|
||||
@ -149,8 +158,8 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
|
||||
for (uint8_t i = 0; i < NUM_OF_TIMER; i++) {
|
||||
if (htim == timerSupport[i].handle) {
|
||||
timerSupport[i].slotCnt++;
|
||||
if (timerSupport[i].slotCnt == NUM_OF_SINE_SLOT + 2) {
|
||||
timerSupport[i].slotCnt = 2;
|
||||
if (timerSupport[i].slotCnt == NUM_OF_SINE_SLOT + 3) {
|
||||
timerSupport[i].slotCnt = 3;
|
||||
HAL_GPIO_TogglePin(timerSupport[i].bridgePolarityPort,
|
||||
timerSupport[i].bridgePolarityPin);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ void testSwitchFrequency3(void *handle) {
|
||||
void my_setup_2() {
|
||||
inverterBegin();
|
||||
|
||||
inverterStart(25, CLOCKWISE);
|
||||
inverterStart(100, CLOCKWISE);
|
||||
// schAdd(testSwitchFrequency1, NULL, 5000, 0);
|
||||
// schAdd(testSwitchFrequency2, NULL, 10000, 0);
|
||||
// schAdd(testSwitchFrequency1, NULL, 15000, 0);
|
||||
|
22
src/main.c
22
src/main.c
@ -212,21 +212,21 @@ static void MX_RTC_Init(void)
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
sTime.Hours = 1;
|
||||
sTime.Minutes = 0;
|
||||
sTime.Seconds = 0;
|
||||
sTime.Hours = 0x1;
|
||||
sTime.Minutes = 0x0;
|
||||
sTime.Seconds = 0x0;
|
||||
|
||||
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK)
|
||||
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
DateToUpdate.WeekDay = RTC_WEEKDAY_MONDAY;
|
||||
DateToUpdate.Month = RTC_MONTH_JANUARY;
|
||||
DateToUpdate.Date = 1;
|
||||
DateToUpdate.Year = 0;
|
||||
DateToUpdate.Date = 0x1;
|
||||
DateToUpdate.Year = 0x0;
|
||||
|
||||
if (HAL_RTC_SetDate(&hrtc, &DateToUpdate, RTC_FORMAT_BIN) != HAL_OK)
|
||||
if (HAL_RTC_SetDate(&hrtc, &DateToUpdate, RTC_FORMAT_BCD) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
@ -241,7 +241,7 @@ static void MX_TIM1_Init(void)
|
||||
TIM_MasterConfigTypeDef sMasterConfig;
|
||||
|
||||
htim1.Instance = TIM1;
|
||||
htim1.Init.Prescaler = 72;
|
||||
htim1.Init.Prescaler = 36;
|
||||
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim1.Init.Period = 5000;
|
||||
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
@ -275,7 +275,7 @@ static void MX_TIM2_Init(void)
|
||||
TIM_OC_InitTypeDef sConfigOC;
|
||||
|
||||
htim2.Instance = TIM2;
|
||||
htim2.Init.Prescaler = 72;
|
||||
htim2.Init.Prescaler = 36;
|
||||
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim2.Init.Period = 5000;
|
||||
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
@ -324,7 +324,7 @@ static void MX_TIM4_Init(void)
|
||||
TIM_OC_InitTypeDef sConfigOC;
|
||||
|
||||
htim4.Instance = TIM4;
|
||||
htim4.Init.Prescaler = 72;
|
||||
htim4.Init.Prescaler = 36;
|
||||
htim4.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim4.Init.Period = 5000;
|
||||
htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
@ -373,7 +373,7 @@ static void MX_TIM5_Init(void)
|
||||
TIM_OC_InitTypeDef sConfigOC;
|
||||
|
||||
htim5.Instance = TIM5;
|
||||
htim5.Init.Prescaler = 72;
|
||||
htim5.Init.Prescaler = 36;
|
||||
htim5.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim5.Init.Period = 5000;
|
||||
htim5.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
|
@ -208,21 +208,21 @@ static void MX_RTC_Init(void)
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
sTime.Hours = 1;
|
||||
sTime.Minutes = 0;
|
||||
sTime.Seconds = 0;
|
||||
sTime.Hours = 0x1;
|
||||
sTime.Minutes = 0x0;
|
||||
sTime.Seconds = 0x0;
|
||||
|
||||
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK)
|
||||
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
DateToUpdate.WeekDay = RTC_WEEKDAY_MONDAY;
|
||||
DateToUpdate.Month = RTC_MONTH_JANUARY;
|
||||
DateToUpdate.Date = 1;
|
||||
DateToUpdate.Year = 0;
|
||||
DateToUpdate.Date = 0x1;
|
||||
DateToUpdate.Year = 0x0;
|
||||
|
||||
if (HAL_RTC_SetDate(&hrtc, &DateToUpdate, RTC_FORMAT_BIN) != HAL_OK)
|
||||
if (HAL_RTC_SetDate(&hrtc, &DateToUpdate, RTC_FORMAT_BCD) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
@ -237,7 +237,7 @@ static void MX_TIM1_Init(void)
|
||||
TIM_MasterConfigTypeDef sMasterConfig;
|
||||
|
||||
htim1.Instance = TIM1;
|
||||
htim1.Init.Prescaler = 72;
|
||||
htim1.Init.Prescaler = 36;
|
||||
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim1.Init.Period = 5000;
|
||||
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
@ -271,7 +271,7 @@ static void MX_TIM2_Init(void)
|
||||
TIM_OC_InitTypeDef sConfigOC;
|
||||
|
||||
htim2.Instance = TIM2;
|
||||
htim2.Init.Prescaler = 72;
|
||||
htim2.Init.Prescaler = 36;
|
||||
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim2.Init.Period = 5000;
|
||||
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
@ -320,7 +320,7 @@ static void MX_TIM4_Init(void)
|
||||
TIM_OC_InitTypeDef sConfigOC;
|
||||
|
||||
htim4.Instance = TIM4;
|
||||
htim4.Init.Prescaler = 72;
|
||||
htim4.Init.Prescaler = 36;
|
||||
htim4.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim4.Init.Period = 5000;
|
||||
htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
@ -369,7 +369,7 @@ static void MX_TIM5_Init(void)
|
||||
TIM_OC_InitTypeDef sConfigOC;
|
||||
|
||||
htim5.Instance = TIM5;
|
||||
htim5.Init.Prescaler = 72;
|
||||
htim5.Init.Prescaler = 36;
|
||||
htim5.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim5.Init.Period = 5000;
|
||||
htim5.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user