原创 STM32通用程序编写

2009-12-17 15:59 2272 3 3 分类: MCU/ 嵌入式

1.配置某位引脚输出


  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIO_LED, &GPIO_InitStructure);


2.开始定时器


  TIM_TimeBa seStructure.TIM_Period = 0x4AF;   
  TIM_TimeBaseStructure.TIM_Prescaler = 0xEA5F              TIM_TimeBaseStructure.TIM_ClockDivision = 0x0  TIM_TimeBaseStructure.TIM_CounterMode = ounterMode_Up   TIM_TimeBaseStructure.TIM_RepetitionCounter = 0x0000;
  TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure)


TIM_Cmd(TIM2, ENABLE);


 TIM_PrescalerConfig(TIM2, 0xEA5F, ReloadMode_Immediate);


TIM_ClearFlag(TIM2, TIM_FLAG_Update);


TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);


 

PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
3
关闭 站长推荐上一条 /3 下一条