cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using HRTIM with HAL on STM32F334

HastyHarry
Associate II

Hi,

I have stucked trying to use hrtim pwm outputs on stm32f334r8.

I use initialisation provided by CubeMX to start all 10 channels right now. I use exactly the same setting for every channel, but still have different results.

It is not possible to fit init code here, but here the main parts:

//TIMER CONFIG START
	pTimeBaseCfg.Period = 0x0960;
  pTimeBaseCfg.RepetitionCounter = 0x00;
  pTimeBaseCfg.PrescalerRatio = HRTIM_PRESCALERRATIO_DIV1;
  pTimeBaseCfg.Mode = HRTIM_MODE_CONTINUOUS;
  //WAVEFORM TIMER CONFIG START
  pTimerCfg.InterruptRequests = HRTIM_TIM_IT_NONE;
  pTimerCfg.DMARequests = HRTIM_TIM_DMA_NONE;
  pTimerCfg.DMASrcAddress = 0x0000;
  pTimerCfg.DMADstAddress = 0x0000;
  pTimerCfg.DMASize = 0x1;
  pTimerCfg.PushPull = HRTIM_TIMPUSHPULLMODE_DISABLED;
  pTimerCfg.FaultEnable = HRTIM_TIMFAULTENABLE_NONE;
  pTimerCfg.FaultLock = HRTIM_TIMFAULTLOCK_READWRITE;
  pTimerCfg.DeadTimeInsertion = HRTIM_TIMDEADTIMEINSERTION_ENABLED;
  pTimerCfg.DelayedProtectionMode = HRTIM_TIMER_A_B_C_DELAYEDPROTECTION_DISABLED;
  pTimerCfg.UpdateTrigger = HRTIM_TIMUPDATETRIGGER_NONE;
  pTimerCfg.ResetTrigger = HRTIM_TIMRESETTRIGGER_NONE;
  pTimerCfg.ResetUpdate = HRTIM_TIMUPDATEONRESET_DISABLED;
	//COMPARE CONFIG START
  pCompareCfg.CompareValue = 0x04b0;
  //DEADTIME CONFIG START
  pDeadTimeCfg.Prescaler = HRTIM_TIMDEADTIME_PRESCALERRATIO_DIV1;
  pDeadTimeCfg.RisingValue = 0x050;
  pDeadTimeCfg.RisingSign = HRTIM_TIMDEADTIME_RISINGSIGN_POSITIVE;
  pDeadTimeCfg.RisingLock = HRTIM_TIMDEADTIME_RISINGLOCK_WRITE;
  pDeadTimeCfg.RisingSignLock = HRTIM_TIMDEADTIME_RISINGSIGNLOCK_WRITE;
  pDeadTimeCfg.FallingValue = 0x050;
  pDeadTimeCfg.FallingSign = HRTIM_TIMDEADTIME_FALLINGSIGN_POSITIVE;
  pDeadTimeCfg.FallingLock = HRTIM_TIMDEADTIME_FALLINGLOCK_WRITE;
  pDeadTimeCfg.FallingSignLock = HRTIM_TIMDEADTIME_FALLINGSIGNLOCK_WRITE;
  //OUTPUTS CONFIG START
  pOutputCfg.Polarity = HRTIM_OUTPUTPOLARITY_HIGH;
  pOutputCfg.SetSource = HRTIM_OUTPUTSET_TIMPER; //doesn't work with res
  pOutputCfg.ResetSource = HRTIM_OUTPUTRESET_TIMCMP1;
  pOutputCfg.IdleMode = HRTIM_OUTPUTIDLEMODE_NONE;
  pOutputCfg.IdleLevel = HRTIM_OUTPUTIDLELEVEL_INACTIVE;
  pOutputCfg.FaultLevel = HRTIM_OUTPUTFAULTLEVEL_NONE;
  pOutputCfg.ChopperModeEnable = HRTIM_OUTPUTCHOPPERMODE_DISABLED;
  pOutputCfg.BurstModeEntryDelayed = HRTIM_OUTPUTBURSTMODEENTRY_REGULAR;

You can see the result on the images. Outputs A and E works great. Output B doesn't work at all. C has strange mistake - both outputs are the same, not opposite. C also has some problems with PWM, because of deadtime. D has same problems with pulses.

So the main question is simple as usual - what am i doing wrong here?)

UPD: Found another strange thing:

if I run all the timers, but start only pwm generation on A,D,E - I got nothing on TD1 while TD2 is working.

1 ACCEPTED SOLUTION

Accepted Solutions
HastyHarry
Associate II

Sorry guys, my mistake. It looks like I have a hardware problem.

View solution in original post

2 REPLIES 2
HastyHarry
Associate II

Rewrote hrtim code using registers. Found that problem with B channel was connected with Fault input pin, that wasn't initialized properly. Still haven't found what is wrong with C.

HastyHarry
Associate II

Sorry guys, my mistake. It looks like I have a hardware problem.