2015-11-25 08:48 AM
I cannot find any function which allow me to change the reload value (supposedly stored in ....Init.Period member of the timer struct). Should I rerun Cube MX and change the counter period in the the TIM21 settings panel? is there any drawback on changing this on the fly?
thanks2015-11-25 09:51 AM
Couldn't you use something like TIM21->ARR = NewPeriod; ?
The preload settings would determine if this is taken immediately, or at the next update.2015-11-26 02:04 AM
h
ello clive
I found this macro which does the job __HAL_TIM_SET_COMPARE(&htim21, 1, 6400/2);Then I cannot make the OC feature for TIM21 working: I am having Nucleo64 (STM32L053) as target I want to use the TIM21 OC for generating a periodic square wave at PB13 (OC channel 1). I set up the project with CubeMX enabling TIM21 output compare etc.To check the PB13 is alive I tried first to set the OCMODE to 'forced output' sConfigOC.OCMode = TIM_OCMODE_FORCED_ACTIVE;I then was expecting PB13 goes high but this does not happen :(I then went back to the option as generate by CubeMxsConfigOC.OCMode = TIM_OCMODE_TOGGLE;
I set AAR = 6400(htim21.Init.Period = 6400;)and the comapre register at 3200 for channel 1 __HAL_TIM_SET_COMPARE(&htim21, 1, 6400/2);Before the while(1) loop I execute //HAL_TIM_Base_Start(&htim21); HAL_TIM_OC_Start(&htim21, 1);expecting a waveform with 50%% duty cycle with 6400 clock cycle of period.APB13=0 forever ...please advice (I feel I am doing something completely wrong)