2016-07-06 10:27 AM
Hello.
I am working on project where i need to make 100-500W power supply from 12 to +-24V. I decided to use STM32F334 since it has PWM resolution of 217ps. I tested this, and it looks like it working, it also have spread spectrum function, do to noise inside this timer. ( but it is very narrow) because i need +-24V power supply from 12V, i figure i can servo +24V with one fet, and -24V with other, and i just need devider and inverting opamp, make PID loop, it is simple. What is not simple, i can't get Push Pull topology working. I am always getting inverted respect to each other outputs. I am using PA8 (HRTIM1_CH1) and PA9 (HRTIM1_CH2) All i need is function to set independend mosfet duty cycle, as well as i can't make than high at the sime time ( i will have math to check it, and hardware to prevent it) Does any one know and how i need to change PWM code, so it will work in simple push pull mode ?HRTIM_SlaveSetCompare(HRTIM1, HRTIM_TIMERINDEX_TIMER_A, HRTIM_COMPAREUNIT_1, CCR_CH1);
And this is my configuration. right now it gives out 125KHz with 18432 period, so it is nice. Does any one know how to make this work for simple Push Pull with regulated CH1 and CH2 independently ? I will be very happy for any information.
Reference manual is quite hard to work with somehow...
static void HRTIM_Config(void)
{
HRTIM_OutputCfgTypeDef HRTIM_TIM_OutputStructure;
HRTIM_BaseInitTypeDef HRTIM_BaseInitStructure;
HRTIM_TimerInitTypeDef HRTIM_TimerInitStructure;
HRTIM_TimerCfgTypeDef HRTIM_TimerWaveStructure;
HRTIM_CompareCfgTypeDef HRTIM_CompareStructure;
HRTIM_DeadTimeCfgTypeDef HRTIM_TIM_DeadTimeStructure;
HRTIM_FaultCfgTypeDef HRTIM_FaultCfgStructure;
//HRTIM_ADCTriggerCfgTypeDef HRTIM_ADCTrigStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_HRTIM1CLKConfig(RCC_HRTIM1CLK_PLLCLK);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_HRTIM1, ENABLE);
HRTIM_DLLCalibrationStart(HRTIM1, HRTIM_CALIBRATIONRATE_14);
HRTIM1_COMMON->DLLCR |= HRTIM_DLLCR_CALEN;
while(HRTIM_GetCommonFlagStatus(HRTIM1, HRTIM_ISR_DLLRDY) == RESET);
/* --------------------------------------------------- */
/* TIMERA initialization: timer mode and PWM frequency */
/* --------------------------------------------------- */
HRTIM_TimerInitStructure.HalfModeEnable = HRTIM_HALFMODE_DISABLED;
HRTIM_TimerInitStructure.StartOnSync = HRTIM_SYNCSTART_DISABLED;
HRTIM_TimerInitStructure.ResetOnSync = HRTIM_SYNCRESET_DISABLED;
HRTIM_TimerInitStructure.DACSynchro = HRTIM_DACSYNC_NONE;
HRTIM_TimerInitStructure.PreloadEnable = HRTIM_PRELOAD_ENABLED;
HRTIM_TimerInitStructure.UpdateGating = HRTIM_UPDATEGATING_INDEPENDENT;
HRTIM_TimerInitStructure.BurstMode = HRTIM_TIMERBURSTMODE_MAINTAINCLOCK;
HRTIM_TimerInitStructure.RepetitionUpdate = HRTIM_UPDATEONREPETITION_ENABLED;
HRTIM_BaseInitStructure.Period = BUCK_PWM_PERIOD; /* 400kHz switching frequency */
HRTIM_BaseInitStructure.RepetitionCounter = 127; /* 1 ISR every 128 PWM periods */
HRTIM_BaseInitStructure.PrescalerRatio = HRTIM_PRESCALERRATIO_MUL32;
HRTIM_BaseInitStructure.Mode = HRTIM_MODE_CONTINOUS;
HRTIM_Waveform_Init(HRTIM1, HRTIM_TIMERINDEX_TIMER_A, &HRTIM_BaseInitStructure, &HRTIM_TimerInitStructure);
/* ------------------------------------------------ */
/* TIMERA output and registers update configuration */
/* ------------------------------------------------ */
HRTIM_TimerWaveStructure.DeadTimeInsertion = HRTIM_TIMDEADTIMEINSERTION_ENABLED;
HRTIM_TimerWaveStructure.DelayedProtectionMode = HRTIM_TIMDELAYEDPROTECTION_DISABLED;
HRTIM_TimerWaveStructure.FaultEnable = HRTIM_TIMFAULTENABLE_FAULT1;
HRTIM_TimerWaveStructure.FaultLock = HRTIM_TIMFAULTLOCK_READWRITE;
HRTIM_TimerWaveStructure.PushPull = HRTIM_TIMPUSHPULLMODE_ENABLED;//HRTIM_TIMPUSHPULLMODE_DISABLED;
HRTIM_TimerWaveStructure.ResetTrigger = HRTIM_TIMRESETTRIGGER_NONE;
HRTIM_TimerWaveStructure.ResetUpdate = HRTIM_TIMUPDATEONRESET_DISABLED;
HRTIM_TimerWaveStructure.UpdateTrigger = HRTIM_TIMUPDATETRIGGER_NONE;
HRTIM_WaveformTimerConfig(HRTIM1, HRTIM_TIMERINDEX_TIMER_A, &HRTIM_TimerWaveStructure);
/* -------------------------------- */
/* TA1 and TA2 waveform description */
/* -------------------------------- */
/* PWM on TA1, protected by Fault input */
HRTIM_TIM_OutputStructure.Polarity = HRTIM_OUTPUTPOLARITY_HIGH;
HRTIM_TIM_OutputStructure.SetSource = HRTIM_OUTPUTSET_TIMPER;
HRTIM_TIM_OutputStructure.ResetSource = HRTIM_OUTPUTRESET_TIMCMP1;
HRTIM_TIM_OutputStructure.IdleMode = HRTIM_OUTPUTIDLEMODE_NONE;
HRTIM_TIM_OutputStructure.IdleState = HRTIM_OUTPUTIDLESTATE_INACTIVE;
HRTIM_TIM_OutputStructure.FaultState = HRTIM_OUTPUTFAULTSTATE_INACTIVE;
HRTIM_TIM_OutputStructure.ChopperModeEnable = HRTIM_OUTPUTCHOPPERMODE_DISABLED;
HRTIM_TIM_OutputStructure.BurstModeEntryDelayed = HRTIM_OUTPUTBURSTMODEENTRY_REGULAR;
HRTIM_WaveformOutputConfig(HRTIM1, HRTIM_TIMERINDEX_TIMER_A, HRTIM_OUTPUT_TD1, &HRTIM_TIM_OutputStructure);
/* Set compare registers for duty cycle on TA1 */
HRTIM_CompareStructure.AutoDelayedMode = HRTIM_AUTODELAYEDMODE_REGULAR;
HRTIM_CompareStructure.AutoDelayedTimeout = 0;
HRTIM_CompareStructure.CompareValue = BUCK_PWM_PERIOD/10; /* 5% duty cycle */
HRTIM_WaveformCompareConfig(HRTIM1, HRTIM_TIMERINDEX_TIMER_A, HRTIM_COMPAREUNIT_1, &HRTIM_CompareStructure);
HRTIM_TIM_DeadTimeStructure.FallingLock = HRTIM_TIMDEADTIME_FALLINGLOCK_WRITE;
HRTIM_TIM_DeadTimeStructure.FallingSign = HRTIM_TIMDEADTIME_FALLINGSIGN_POSITIVE;
HRTIM_TIM_DeadTimeStructure.FallingSignLock = HRTIM_TIMDEADTIME_FALLINGSIGNLOCK_WRITE;
HRTIM_TIM_DeadTimeStructure.FallingValue = DT_FALLING;
HRTIM_TIM_DeadTimeStructure.Prescaler = 0x0;
HRTIM_TIM_DeadTimeStructure.RisingLock = HRTIM_TIMDEADTIME_RISINGLOCK_WRITE;
HRTIM_TIM_DeadTimeStructure.RisingSign = HRTIM_TIMDEADTIME_RISINGSIGN_POSITIVE;
HRTIM_TIM_DeadTimeStructure.RisingSignLock = HRTIM_TIMDEADTIME_RISINGSIGNLOCK_WRITE;
HRTIM_TIM_DeadTimeStructure.RisingValue = DT_RISING;
HRTIM_DeadTimeConfig(HRTIM1, HRTIM_TIMERINDEX_TIMER_A, &HRTIM_TIM_DeadTimeStructure);
/* --------------------------*/
/* ADC trigger initialization */
/* --------------------------*/
/* Set compare 3 registers for ADC trigger */
//HRTIM_CompareStructure.AutoDelayedMode = HRTIM_AUTODELAYEDMODE_REGULAR;
//HRTIM_CompareStructure.AutoDelayedTimeout = 0;
//HRTIM_CompareStructure.CompareValue = BUCK_PWM_PERIOD/10; /* samples in middle of duty cycle */
//HRTIM_WaveformCompareConfig(HRTIM1, HRTIM_TIMERINDEX_TIMER_A, HRTIM_COMPAREUNIT_2, &HRTIM_CompareStructure);
//HRTIM_ADCTrigStructure.Trigger = HRTIM_ADCTRIGGEREVENT24_TIMERA_CMP2;
//HRTIM_ADCTrigStructure.UpdateSource = HRTIM_ADCTRIGGERUPDATE_TIMER_D;
//HRTIM_ADCTriggerConfig(HRTIM1, HRTIM_ADCTRIGGER_2, &HRTIM_ADCTrigStructure);
/* --------------------*/
/* FAULT initialization */
/* --------------------*/
HRTIM_FaultCfgStructure.Filter = HRTIM_FAULTFILTER_NONE;
HRTIM_FaultCfgStructure.Lock = HRTIM_FAULTLOCK_READWRITE;
HRTIM_FaultCfgStructure.Polarity = HRTIM_FAULTPOLARITY_LOW;
HRTIM_FaultCfgStructure.Source = HRTIM_FAULTSOURCE_DIGITALINPUT;
HRTIM_FaultConfig(HRTIM1, &HRTIM_FaultCfgStructure, HRTIM_FAULT_1);
HRTIM_FaultModeCtl(HRTIM1, HRTIM_FAULT_1, HRTIM_FAULT_ENABLED);
/* -------------------------*/
/* Interrupt initialization */
/* -------------------------*/
/* Configure and enable HRTIM TIMERA interrupt channel in NVIC */
NVIC_InitStructure.NVIC_IRQChannel = HRTIM1_TIMA_IRQn;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* TIMER A issues an interrupt on each repetition event */
HRTIM_ITConfig(HRTIM1, HRTIM_TIMERINDEX_TIMER_A, HRTIM_TIM_IT_REP, ENABLE);
/* ---------------*/
/* HRTIM start-up */
/* ---------------*/
/* Enable HRTIM's outputs TA1 and TA2 */
/* Note: it is necessary to enable also GPIOs to have outputs functional */
HRTIM_WaveformOutputStart(HRTIM1, HRTIM_OUTPUT_TA1 | HRTIM_OUTPUT_TA2);
/* Start HRTIM's TIMER A */
HRTIM_WaveformCounterStart(HRTIM1, HRTIM_TIMERID_TIMER_A);
}
2016-07-20 05:31 AM
Any one ?
2016-10-26 05:39 AM
Hi
karpavicius.linas, I recommend to get help to develop your HRTIM application from the following sources:- Application note- Application note- Ready-to-use examples ''HRTIM_BuckBoost'' and ''HRTIM_BuckBoost_AN4449'' ''HRTIM_snippet'' you find at the STM32CubeF3 at this path: STM32Cube_FW_F3_V1.6.0\Projects\STM32F3348-Discovery\Examples\HRTIM-> You check the STM32F3xx_it.c file where the IRQ Handlers are called-Hannibal-