cancel
Showing results for 
Search instead for 
Did you mean: 

TIM2 DMA PWM to PA2 get no effect

Jseyn.1
Associate III

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.

5 REPLIES 5
Jseyn.1
Associate III

here is tim2 register:

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
Associate III

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

Jseyn.1
Associate III

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;

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

JW