STM32定时器TIM8为什麽没有PWM输出?
答案:6 悬赏:60 手机版
解决时间 2021-02-05 09:59
- 提问者网友:寂寞撕碎了回忆
- 2021-02-04 09:57
STM32定时器TIM8为什麽没有PWM输出?
最佳答案
- 五星知识达人网友:鸽屿
- 2021-02-04 11:13
先看一下你用的哪一种型号的stm32,TIM8是高级定时器,只有大容量产品(闪存存储器容量在256K至512K字节之间)才具有追问STM32F103ZET6
全部回答
- 1楼网友:罪歌
- 2021-02-04 16:01
这是由生产厂家决定的。没有为什么。
- 2楼网友:鱼芗
- 2021-02-04 14:40
你用的那个型号啊?那个系列
- 3楼网友:一袍清酒付
- 2021-02-04 13:43
硬件平台为STM32103VE,编译环境为KEIL uVision3。利用高级控制定时器TIM1和TIM8分别产生PWM波形,TIM1和TIM8相关初始化代码完全一致,但在实际软件仿真运行中,利用软件自带的逻辑分析仪工具监测TIM1_CH1(PA8)和TIM8_CH1(PC6)输出逻辑,结果发现TIM1_CH1(PA8)波形正常,而TIM8_CH1(PC6)仿真无输出,但下载到FLASH脱机运行实测是有波形输出的。
初始化代码如下:
void TIM8_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
//GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
GPIO_Init(GPIOB, &GPIO_InitStructure);
TIM_DeInit(TIM8);
TIM_TimeBaseStructure.TIM_Prescaler = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_Period = 4095;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM8, &TIM_TimeBaseStructure);
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable;
TIM_OCInitStructure.TIM_Pulse = CCR1_Val;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_Low;
TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set;
TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset;
TIM_OC1Init(TIM8, &TIM_OCInitStructure);
TIM_OCInitStructure.TIM_Pulse = CCR2_Val;
TIM_OC2Init(TIM8, &TIM_OCInitStructure);
TIM_OCInitStructure.TIM_Pulse = CCR3_Val;
TIM_OC3Init(TIM8, &TIM_OCInitStructure);
TIM_Cmd(TIM8, ENABLE);
TIM_CtrlPWMOutputs(TIM8, ENABLE);
}
- 4楼网友:掌灯师
- 2021-02-04 12:48
TIM8是高级定时器,闪存存储器容量在256K至512K字节之间才具有
- 5楼网友:独行浪子会拥风
- 2021-02-04 12:12
你是用库函数好的还是寄存器操作的,
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯