stm8s timer1 死区设置为什么 没有出现死区反而 oc1和oc1n的输出高脉冲头重叠增加了?求大神解答

2019-07-19 20:43发布

/* MAIN.C file  *   * Copyright (c) 2002-2005 STMicroelectronics  */

#include "stm8s207c.h" // 声明中断服务函数 _Bool ZKBJ @PD_IDR:4; _Bool ZKBQ @PB_IDR:7; _Bool ZZ   @PB_ODR:6; _Bool LED  @PC_ODR:3; _Bool LED1 @PC_ODR:4;
/* 函数声明----------------------------------------------------------------------*/ /* TIM1_PWM初始化 */ void TIM1_PWM_init(void); void CLK_Init(void); void GPIO_Init(void); void SCZWH_Init(void); void SCZWL_Init(void); void SCZWH_Int(void); void SCZWL_Int(void); void DELAY (unsigned int x); //void EXTI0_Init(void); //void EXTI3_Init(void);
void main(void) {       _asm("sim");  GPIO_Init();      CLK_Init(); _asm("rim");         TIM1_PWM_init();         while(1); }
/**** * 函数功能: TIM1_PWM初始化 * 参数: 无 * 返回值: 无 */ void CLK_Init(void) {  CLK_SWR = 0xB4; while(!(CLK_SWCR&0x08)); CLK_SWCR |=0x02; while(CLK_CMSR!=0xB4); CLK_CSSR |=0x01;  CLK_CKDIVR = 0x00; CLK_PCKENR1 = 0x80; }
void GPIO_Init(void) { PB_DDR = 0x03; PB_CR1 = 0x0F; //PB_CR2 |= 0x03; PC_DDR |= 0x06; PC_DDR |= 0X18; PC_CR1 |= 0X18; PC_CR1 |= 0x06; PC_CR2 |= 0x06; PC_CR1 |= 0x08; PC_CR2 |= 0x00; }
void TIM1_PWM_init(void) {         TIM1_ARRH = 0x00;        // 计数周期         TIM1_ARRL = 0x20;         TIM1_CCR1H = 0x00;        // TIM1比较/捕获寄存器1         TIM1_CCR1L = 0x0b; TIM1_CCR2H = 0x00; TIM1_CCR2L = 0x0b;         TIM1_PSCRH = 0;                // 分频比         TIM1_PSCRL = 1;                  TIM1_CR1 |= 0x20;        // CMS(01) : Center-aligned mode 1         TIM1_CR1 |= 0x80;        // set ARPE TIM1_IER |= 0x03; TIM1_IER |= 0x04; //TIM1_IER |= 0x20; //TIM1_IER |= 0x40; //TIM1_IER |= 0x80;         TIM1_CCMR1 |= 0x60;        // OC1M(110) : PWM Mode 1         TIM1_CCMR1 |= 0x08; // set OC1PE TIM1_CCMR2 |= 0x60;  TIM1_CCMR2 |= 0x08;          TIM1_CCER1 |= 0x01;        // set CC1E         TIM1_CCER1 |= 0x08;        // set CC1NP         TIM1_CCER1 |= 0x04;        // set CC1NE TIM1_CCER1 |= 0x02; TIM1_CCER1 |= 0x10;        // set CC1E         TIM1_CCER1 |= 0x20;        // set CC1NP         TIM1_CCER1 |= 0x40;        // set CC1NE TIM1_CCER1 |= 0x80;         TIM1_CR2 |= 0x01;        // set CCPC TIM1_CR2 |= 0x04; TIM1_CR2 |= 0x04;         TIM1_EGR |= 0x20;        // set COMG         TIM1_DTR = 0x05;        // Deadtime generator         TIM1_BKR |= 0x08;        // set OSSR         TIM1_BKR |= 0x80;        // set MOE         TIM1_CR1 |= 0x01;        // 开启计数? TIM1_OISR |= 0x0f; }
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
3条回答
正点原子
1楼-- · 2019-07-20 01:47
帮顶
背成一把刀
2楼-- · 2019-07-20 05:51
 精彩回答 2  元偷偷看……
专业电路板开发
3楼-- · 2019-07-20 06:13
 精彩回答 2  元偷偷看……

一周热门 更多>