2016-10-17 08:46 PM
Hi,
I'm trying to use the HRTIM for a high resolution simple PWM signal, using HAL. If I set the pulse length in the HRTIM initialise routine, then call SimplePWMStart() then I get the correct PWM output. However, the __HAL_HRTIM_SETCOMPARE macro does not change the output period. Is there some trick to using this macro? I'm using the STM32F334R8Tx Nucleo board. <code> int main(void) { /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_USART2_UART_Init(); MX_HRTIM1_Init(); HAL_HRTIM_SimplePWMStart(&hhrtim1,HRTIM_TIMERINDEX_TIMER_A, HRTIM_OUTPUT_TA1); // this does start the PWM running __HAL_HRTIM_SETCOMPARE(&hhrtim1, HRTIM_TIMERINDEX_TIMER_A, HRTIM_COMPAREUNIT_1, 0x1000); // DOES NOTHING!!! /* HRTIM1 init function */ void MX_HRTIM1_Init(void) { HRTIM_TimeBaseCfgTypeDef pTimeBaseCfg; HRTIM_SimplePWMChannelCfgTypeDef pSimplePWMChannelCfg; hhrtim1.Instance = HRTIM1; hhrtim1.Init.HRTIMInterruptResquests = HRTIM_IT_NONE; hhrtim1.Init.SyncOptions = HRTIM_SYNCOPTION_NONE; if (HAL_HRTIM_Init(&hhrtim1) != HAL_OK) { Error_Handler(); } if (HAL_HRTIM_DLLCalibrationStart(&hhrtim1, HRTIM_CALIBRATIONRATE_14) != HAL_OK) { Error_Handler(); } if (HAL_HRTIM_PollForDLLCalibration(&hhrtim1, 10) != HAL_OK) { Error_Handler(); } pTimeBaseCfg.Period = 0xFFF7; pTimeBaseCfg.RepetitionCounter = 0x00; pTimeBaseCfg.PrescalerRatio = HRTIM_PRESCALERRATIO_MUL8; pTimeBaseCfg.Mode = HRTIM_MODE_CONTINUOUS; if (HAL_HRTIM_TimeBaseConfig(&hhrtim1, HRTIM_TIMERINDEX_TIMER_A, &pTimeBaseCfg) != HAL_OK) { Error_Handler(); } pSimplePWMChannelCfg.Pulse = 0xFFDF; pSimplePWMChannelCfg.Polarity = HRTIM_OUTPUTPOLARITY_HIGH; pSimplePWMChannelCfg.IdleLevel = HRTIM_OUTPUTIDLELEVEL_INACTIVE; if (HAL_HRTIM_SimplePWMChannelConfig(&hhrtim1, HRTIM_TIMERINDEX_TIMER_A, HRTIM_OUTPUT_TA1, &pSimplePWMChannelCfg) != HAL_OK) { Error_Handler(); } HAL_HRTIM_MspPostInit(&hhrtim1); } #hrtim2016-10-18 08:39 AM
Hello marks.sasha,
You can follow the HRTIM example under STM32CubeF3 to identify what is going wrong in your case: STM32Cube_FW_F3_V1.6.0\Projects\STM32F3348-Discovery\Examples\HRTIMYou can compare your generated code with this provided application and check your needed functions with regarding passed parameters.Regards2016-10-19 09:46 PM
Thanks for your reply, but I could not find any examples using the SimplePWM HAL methods. I think the problem is that using SimplePWM methods, the register pre-load is enabled - how do I force the preload register to be copied across to the active register? I can't find any info on this in the HAL manual.
2016-10-26 05:39 AM
Hi marks.sasha,
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-