cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Timer Interrupts , mode Slave , Toggle on match

gevmar
Associate III
Hello everyone, I'm asking for your advice. I use stm32f429i-DISC1 board with display(I use) , HCLK = 96 MHz , APB1 = 48 MHz..., 
I start the for example timer_1,  output compare CH1 (output)
mode=toggle on match ; ...preload = Enable ... , counter period = 500 nSec ; CH1 output is ok ,
but in parallel with this, I want to be able to implement internal interrupts in each period(500nSec) 
and output a certain value to the some pin, 
 
but when I start this functions my display begins to not work , 
///  __HAL_TIM_ENABLE_IT(&htim1, TIM_IT_UPDATE); /// conflicted with display   ///   
or
///  HAL_TIM_Base_Start_IT() (Not Recommended)   /// conflicted with display   ///  
 
and 
 
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
//if (htim->Instance == TIM1)
if(htim == &htim2 )
{
  HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_2);
 
..........
}
 
and I see that the fastest speed of this interrupt is 2.5 uSec but not 500 nSec . 
 
why is this so ?
How can I solve this issue ?
3 REPLIES 3

It takes time to execute the interrupt service routine. MHz interrupt rates are irrational, especially so if you use Cube/HAL.

JW

gevmar
Associate III

Thank you very much for your response,

but what can you recommend,
is there any other library in CubeIDE(without HAL) that can improve the situation for the better? .(I didnt want to use assembler)
For example I checked the external interrupt , and that is delayed in HAL by about 350ns.


But there is I have one more incomprehensible problem, I started the timer_1 in slave mode,
I started PWM in mode DMA . How can I make the DMA start counting(reset count) the array(my_pwm_Data[]) from scratch(zero position),
with the arrival of the timer trigger signal(from another Timer) . The period of the trigger signal is 100 µsec,
and the period of the slave timer itself is 1 µsec.

Becouse my PWM variable 0 position (my_pwm_Data[0]  )   does not match with my trigger signal start .

uint16_t my_pwm_Data[100] = {0,1,2,.....} ;
...................
uint16_t my_PWM_period_count_length = 100 ;   /////   param Length The length of data to be transferred from                                                                                        /////         memory to TIM peripheral

HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_3, (uint32_t*)my_pwm_Data, my_PWM_period_count_length) ;

 

thank you in advance 

gevmar
Associate III

SLAVE MODE = RESET MODE
AUTO-RELOAD PRELOAD = Enable
DMA SETTINGS = TIM1_CH3 ; MEMORY TO PERIPHERAL ; INCREMENT ADDRESS MEMORY = YES ; LENGTH = Half Word