stdebug 发表于 2016-4-28 10:56:26

F030K6 PA9 TIM1_CH2无法输出PWM

TIM1_CH1TIM1_CH3TIM1_CH4正常只有 TIM1_CH2无法输出PWM相同的代码应用在F030R8上TIM1_CH1TIM1_CH2TIM1_CH3TIM1_CH4 都正常。

stdebug 发表于 2016-4-28 11:01:21

CH3 红色为R8 PA9 PWM
CH1 黄色为K6 PA9 PWM

stdebug 发表于 2016-4-28 14:27:45

void LED_Init(void)
{
        GPIO_InitTypeDef GPIO_InitStruct;
        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_8| GPIO_Pin_10;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
GPIO_InitStruct.GPIO_Speed =GPIO_Speed_Level_3;
GPIO_Init(GPIOA, &GPIO_InitStruct);
       
        GPIO_SetBits(GPIOA, GPIO_Pin_9| GPIO_Pin_8| GPIO_Pin_10);
       
        GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
GPIO_InitStruct.GPIO_Speed =GPIO_Speed_Level_3;
GPIO_Init(GPIOB, &GPIO_InitStruct);
        GPIO_SetBits(GPIOB, GPIO_Pin_0);
}

void LED1_Toggle(void)
{
        GPIOA->ODR ^=GPIO_Pin_10;
        GPIOA->ODR ^=GPIO_Pin_9;
        GPIOA->ODR ^=GPIO_Pin_8;
        GPIOB->ODR ^=GPIO_Pin_0;
}

IO口翻转,PA9PB0均无法翻转

xmshao 发表于 2016-4-28 23:11:40

管脚复用配置呢?
GPIO_PinAFConfig(GPIOA, GPIO_PinSource8, GPIO_AF_X);

stdebug 发表于 2016-4-29 09:15:16

xmshao 发表于 2016-4-28 23:11
管脚复用配置呢?
GPIO_PinAFConfig(GPIOA, GPIO_PinSource8, GPIO_AF_X);

用作IO口也需复用?

xmshao 发表于 2016-4-29 15:32:17

做PWM就不是单纯的IO口了。

你到底是要 TIMER做PWM输出还是GPIO翻转输出?

如果只是 GPIO翻转输出当然不要做复用配置,但注意有无其它功能复用,另外也确认下外部线路。
页: [1]
查看完整版本: F030K6 PA9 TIM1_CH2无法输出PWM