打印

香水城:TIMx配置一样会有冲突吗?

[复制链接]
2996|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
worldsing|  楼主 | 2010-4-16 11:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
TI, mx, IO, pi, ni
本帖最后由 worldsing 于 2010-4-16 11:29 编辑

//======================================================================
void Timer_Configuration(void)
{
TIM_TimeBaseInitTypeDef   TIM_TimeBaseStructure;
TIM_OCInitTypeDef      TIM_OCInitStructure;
GPIO_InitTypeDef          GPIO_InitStruct;


//------------------------------TIM2 ch2 PA1---------------------------------------
GPIO_DeInit(GPIOA);
GPIO_InitStruct.GPIO_Pin=GPIO_Pin_0;              //TIM2 CH2 PA0 R47(WAKEUP)
GPIO_InitStruct.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Mode=GPIO_Mode_AF_PP;
GPIO_Init(GPIOA,&GPIO_InitStruct);

TIM_DeInit(TIM2);
TIM_TimeBaseStructure.TIM_Period=400;                 //ARR的值
TIM_TimeBaseStructure.TIM_Prescaler=0;                //PSC分频值
TIM_TimeBaseStructure.TIM_ClockDivision=TIM_CKD_DIV1;           //采样分频
TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up;  //向上计数模式
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);

TIM_PrescalerConfig(TIM2,1,TIM_PSCReloadMode_Immediate);   
TIM_ARRPreloadConfig(TIM2, ENABLE);
  
TIM_OCInitStructure.TIM_OCMode=TIM_OCMode_Toggle;
TIM_OCInitStructure.TIM_Channel=TIM_Channel_1;
TIM_OCInitStructure.TIM_Pulse=200;
TIM_OCInitStructure.TIM_OCPolarity=TIM_OCPolarity_High;
TIM_OCInit(TIM2, &TIM_OCInitStructure);  


//------------------------------TIM3 ch1 PA6---------------------------------------
GPIO_InitStruct.GPIO_Pin=GPIO_Pin_6;     //TIM3 CH1 R14(SPI1_MISO)
GPIO_InitStruct.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Mode=GPIO_Mode_AF_PP;
GPIO_Init(GPIOA,&GPIO_InitStruct);

TIM_DeInit(TIM3);
TIM_TimeBaseStructure.TIM_Period=400;                 //ARR的值
TIM_TimeBaseStructure.TIM_Prescaler=0;                 //PSC分频值
TIM_TimeBaseStructure.TIM_ClockDivision=TIM_CKD_DIV1;           //采样分频
TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up;  //向上计数模式
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);

TIM_PrescalerConfig(TIM3,1,TIM_PSCReloadMode_Immediate);   
TIM_ARRPreloadConfig(TIM3, ENABLE);
  
TIM_OCInitStructure.TIM_OCMode=TIM_OCMode_Toggle;
TIM_OCInitStructure.TIM_Channel=TIM_Channel_1;
TIM_OCInitStructure.TIM_Pulse=200;
TIM_OCInitStructure.TIM_OCPolarity=TIM_OCPolarity_High;
TIM_OCInit(TIM3, &TIM_OCInitStructure);  



//-----------------------------TIM4 ch1 PB6----------------------------------------
GPIO_DeInit(GPIOB);
GPIO_InitStruct.GPIO_Pin=GPIO_Pin_6;               //TIM4 CH1 PB6 TEMP_SCL(J4-22)
GPIO_InitStruct.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Mode=GPIO_Mode_AF_PP;
GPIO_Init(GPIOB,&GPIO_InitStruct);

TIM_DeInit(TIM4);
TIM_TimeBaseStructure.TIM_Period=400;                 //ARR的值
TIM_TimeBaseStructure.TIM_Prescaler=0;                 //PSC分频值
TIM_TimeBaseStructure.TIM_ClockDivision=TIM_CKD_DIV1;           //采样分频
TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up;  //向上计数模式
TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);

TIM_PrescalerConfig(TIM4,1,TIM_PSCReloadMode_Immediate);   
TIM_ARRPreloadConfig(TIM4, ENABLE);
  
TIM_OCInitStructure.TIM_OCMode=TIM_OCMode_Toggle;
TIM_OCInitStructure.TIM_Channel=TIM_Channel_1;
TIM_OCInitStructure.TIM_Pulse=200;
TIM_OCInitStructure.TIM_OCPolarity=TIM_OCPolarity_High;
TIM_OCInit(TIM4, &TIM_OCInitStructure);  

//-----------------------------TIM5 ch1 PA3----------------------------------------
GPIO_DeInit(GPIOB);
GPIO_InitStruct.GPIO_Pin=GPIO_Pin_3;               //TIM4 CH1 PB6
GPIO_InitStruct.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Mode=GPIO_Mode_AF_PP;
GPIO_Init(GPIOA,&GPIO_InitStruct);

TIM_DeInit(TIM5);
TIM_TimeBaseStructure.TIM_Period=400;                 //ARR的值
TIM_TimeBaseStructure.TIM_Prescaler=0;                 //PSC分频值
TIM_TimeBaseStructure.TIM_ClockDivision=TIM_CKD_DIV1;            //采样分频
TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up;  //向上计数模式
TIM_TimeBaseInit(TIM5, &TIM_TimeBaseStructure);

TIM_PrescalerConfig(TIM5,1,TIM_PSCReloadMode_Immediate);   
TIM_ARRPreloadConfig(TIM5, ENABLE);
  
TIM_OCInitStructure.TIM_OCMode=TIM_OCMode_Toggle;
TIM_OCInitStructure.TIM_Channel=TIM_Channel_4;
TIM_OCInitStructure.TIM_Pulse=200;
TIM_OCInitStructure.TIM_OCPolarity=TIM_OCPolarity_High;
TIM_OCInit(TIM5, &TIM_OCInitStructure);  


TIM_Cmd(TIM2, ENABLE);
TIM_Cmd(TIM3, ENABLE);
TIM_Cmd(TIM4, ENABLE);
TIM_Cmd(TIM5, ENABLE);
}


=================================================
我把TIM2 ~ TIM5配置全一样的,结果用示波量,只有TIM2有输出,管脚用的是默认的,所有外设时钟都使能了,会不会是配置成一样的参数,会造成冲突呢?
沙发
香水城| | 2010-4-16 11:33 | 只看该作者
不会造成冲突。

使用特权

评论回复
板凳
worldsing|  楼主 | 2010-4-16 11:36 | 只看该作者
我软仿时,是有输出的,为什么下载到片子里就没有输出波形呢?
会不会硬件有问题?

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

14

主题

346

帖子

0

粉丝