首先说一句抱歉,因为工作的流失,个人国民的测评被中断了,以为已经把测评做完了,昨天晚上才发现在没有弄完,这里再次出测评,这里我使用国民芯片430C8L7自己画的板子代用开发板。
先上TIM的复用功能重映射:有点小,看的不是好清楚。
我把用户用册和规格书传上来方便查阅:
再来个TIM的配置:
TIM_TimeBaseInitType TIM4_TimeBaseStructure;
OCInitType TIM4_OCInitStructure;
PWM_RCC_Configuration();
PWM_GPIO_Configuration();
TIM4_TimeBaseStructure.Period = arr;
TIM4_TimeBaseStructure.Prescaler = psc;
TIM4_TimeBaseStructure.ClkDiv = 0;
TIM4_TimeBaseStructure.CntMode = TIM_CNT_MODE_UP;
TIM_InitTimeBase(TIM4, &TIM4_TimeBaseStructure);
/* PWM1 Mode configuration: Channel1 */
TIM4_OCInitStructure.OcMode = TIM_OCMODE_PWM1;
TIM4_OCInitStructure.OutputState = TIM_OUTPUT_STATE_ENABLE;
/* PWM1 Mode configuration: Channel3 */
TIM4_OCInitStructure.OutputState = TIM_OUTPUT_STATE_ENABLE;
TIM4_OCInitStructure.Pulse = PWM_val;
TIM_InitOc3(TIM4, &TIM4_OCInitStructure);
TIM_ConfigOc3Preload(TIM4, TIM_OC_PRE_LOAD_ENABLE);
TIM_ConfigArPreload(TIM4, ENABLE);
/* TIM4 enable counter */
TIM_Enable(TIM4, ENABLE);
然后在中断函数中配置:
//LED3呼吸灯
if(timer_cont[1] == 2)
{
//呼
if(l_flag == 1)
{
flag2 += 1;
if(flag2 >= 1000)
{
l_flag = 2;
}
}
//吸
else if(l_flag == 2)
{
flag2 -= 1;
if(flag2 < 1)
{
l_flag = 1;
}
下面用灯和手持示波器贴出:
dfec5d36787804f3213d1dece99c085c
|