Skip to main content
Jseyn.1
Associate III
October 21, 2020
Question

TIM2 DMA PWM to PA2 get no effect

  • October 21, 2020
  • 5 replies
  • 1274 views

my type is stm32f031c6. i used TIM2_CH3 binding to DMA1_Channel1 , and set in PWM1_MODE.i find the PA2 no AFIO register to remapping function. the PA2 gotta no PWM pulse.

This topic has been closed for replies.

5 replies

Jseyn.1
Jseyn.1Author
Associate III
October 21, 2020

here is tim2 register:

waclawek.jan
Super User
October 21, 2020

You did not post the registers content. You may want to post TIM, relevant GPIO and DMA registers' content.

Try posting as text. Note, that copy/pasting pictures does not work in this "forum" even if it appears so. If you want post pictures, you have to click on the "picture" icon below the editor and upload picture as file.

JW

Jseyn.1
Jseyn.1Author
Associate III
October 22, 2020

thank you for reply, i find the AFL is not setting. my fault....

Jseyn.1
Jseyn.1Author
Associate III
October 22, 2020

i used stm32f0xx_std_lib

GPIO_PinAFConfig(GPIOA, GPIO_Pin_2, GPIO_AF_2);

void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF)

{

 uint32_t temp = 0x00;

 uint32_t temp_2 = 0x00;

 /* Check the parameters */

 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));

 assert_param(IS_GPIO_PIN_SOURCE(GPIO_PinSource));

 assert_param(IS_GPIO_AF(GPIO_AF));

 temp = ((uint32_t)(GPIO_AF) << ((uint32_t)((uint32_t)GPIO_PinSource & (uint32_t)0x07) * 4));

 GPIOx->AFR[GPIO_PinSource >> 0x03] &= ~((uint32_t)0xF << ((uint32_t)((uint32_t)GPIO_PinSource & (uint32_t)0x07) * 4));

 temp_2 = GPIOx->AFR[GPIO_PinSource >> 0x03] | temp;

 GPIOx->AFR[GPIO_PinSource >> 0x03] = temp_2;

}

the result AFRL is 0x00020000, but the correct value is 0x00000200;

waclawek.jan
Super User
October 22, 2020

I see no problem in this code, so perhaps try to look elsewhere in the program if the register doesn't get overwritten.

JW