cancel
Showing results for 
Search instead for 
Did you mean: 

I want to use the complementary PWM feature in counters except for two advanced timers(because I have a large number of pulses).

amir_pdn
Associate II

I have mastered and timed two timers and can produce both pwm and not pulse. But my problem is that there is no dead time between pulses.

Can you suggest a way for me to have an option like ch1ch1n in other timers that have dead time?

6 REPLIES 6

What's the problem with Advanced timers, exactly?

amir_pdn
Associate II

I have used advanced timers and I need to have more pulses with a specific dead time.

amir_pdn
Associate II

I actually need 6 Plus. (3 pulses (not) are other pulses). I have generated 4 pulses with two timers 1 and 8 and I need to generate two more pulses, but I can not produce deade time with advanced timers

amir_pdn
Associate II

in other words

If I want to have the output (ch1ch1n) that is in timers 1 and 8 and can be produced for dead time pulse in other timers as well.

For further explanation, I have slave and master the two timers together and produce a normal pulse in the master timer and a pulse in the sleeve knot timer. But the problem is dead time.

Then use an STM32 model which has more timers with complementary outputs.

JW

amir_pdn
Associate II

I wrote this code, unfortunately, the accuracy of ARR and CCR is in seconds and does not produce waveforms in microseconds.

Can you suggest a solution to increase the accuracy and resolution of the generated pulses ?????

 /* Initialize all configured peripherals */

 MX_GPIO_Init();

 MX_ADC1_Init();

 MX_TIM2_Init();

 MX_TIM3_Init();

 MX_TIM4_Init();

 MX_UART4_Init();

 MX_TIM7_Init();

 /* USER CODE BEGIN 2 */

TIM2->PSC = 10000 - 1;

TIM2->DIER = TIM_DIER_CC1IE | TIM_DIER_UIE;

TIM2->ARR = 16000;

TIM2->CCR1 = 8000;

TIM2->CR1 = TIM_CR1_CEN;

TIM7->PSC = 10000 - 1;

TIM7->DIER = TIM_DIER_UIE;

TIM7->ARR = 1600;

 /* USER CODE END 2 */

 /* Infinite loop */

 /* USER CODE BEGIN WHILE */

 while (1)

 {

HAL_UART_Transmit(&huart4,(uint8_t*) "Salam\r\n", 7, 10);

HAL_Delay(1000);

  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

 }

AND

void TIM2_IRQHandler(void)

{

 /* USER CODE BEGIN TIM2_IRQn 0 */

if((TIM_SR_CC1IF & TIM2->SR) != 0)

{

MLED_GPIO_Port->BSRR = (MLED_Pin<<16);

GM1_GPIO_Port->BSRR = (GM1_Pin<<16);

// HAL_GPIO_WritePin(MLED_GPIO_Port,MLED_Pin,GPIO_PIN_RESET);

// HAL_GPIO_WritePin(GM1_GPIO_Port,GM1_Pin,GPIO_PIN_RESET);

status = 1;

}

if((TIM_SR_UIF & TIM2->SR) != 0)

{

MLED_GPIO_Port->BSRR = (MLED_Pin);

GM2_GPIO_Port->BSRR = (GM2_Pin<<16);

// HAL_GPIO_WritePin(MLED_GPIO_Port,MLED_Pin,GPIO_PIN_SET);

// HAL_GPIO_WritePin(GM2_GPIO_Port,GM2_Pin,GPIO_PIN_RESET);

status = 2;

 }

TIM7->CNT = 0;

TIM7->CR1 = TIM_CR1_CEN;

 /* USER CODE END TIM2_IRQn 0 */

// HAL_TIM_IRQHandler(&htim2);

 /* USER CODE BEGIN TIM2_IRQn 1 */

TIM2->SR = TIM7->SR & (~(TIM_SR_UIF | TIM_SR_CC1IF));

 /* USER CODE END TIM2_IRQn 1 */

}

/**

 * @brief This function handles TIM3 global interrupt.

 */

void TIM7_IRQHandler(void)

{

 /* USER CODE BEGIN TIM7_IRQn 0 */

if(status == 1)

{

GM2_GPIO_Port->BSRR = (GM2_Pin);

// HAL_GPIO_WritePin(GM2_GPIO_Port,GM2_Pin,GPIO_PIN_SET);

status = 0;

}

else if (status == 2)

{

GM1_GPIO_Port->BSRR = (GM1_Pin);

// HAL_GPIO_WritePin(GM1_GPIO_Port,GM1_Pin,GPIO_PIN_SET);

status = 0;

}

TIM7->CR1 = TIM7->CR1 & (~TIM_CR1_CEN);

 /* USER CODE END TIM7_IRQn 0 */

// HAL_TIM_IRQHandler(&htim7);

 /* USER CODE BEGIN TIM7_IRQn 1 */

TIM7->SR = TIM7->SR & (~TIM_SR_UIF);

 /* USER CODE END TIM7_IRQn 1 */

}

/* USER CODE BEGIN 1 */

/* USER CODE END 1 */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/