将STM32F303CBT6的39脚(B3)复用为TIM8_CH1N,做PWM三相互补输出,发现除TIM8_CH1N外,其他输出均正常,有哪位高手可以指点一下。 /* GPIOB&TIM8 Periph clock enable */ RCC->APB2ENR |= 0x00002000; RCC->AHBENR |= 0x00040000; //IO GPIOB->AFR[0] &= 0x00000FFF; GPIOB->AFR[0] |= 0x55344000; GPIOB->AFR[1] &= 0xFFFFFF00; GPIOB->AFR[1] |= 0x000000AA; /* Speed mode configuration */ GPIOB->OSPEEDR |= 0x000FFFC0; /* Output mode configuration */ GPIOB->OTYPER &= 0xFFFFFC07; GPIOB->UPDR &= 0xFFF0003F; GPIOB->UPDR |= 0x000AAA80; GPIOB->MODER &= 0xFFF0003F; GPIOB->MODER |= 0x000A2A80; /****TimeBaseInit********/ //tDTS=tCK_INT, TIM8_ARR register is not buffered;Center-aligned mode 3 TIM8->CR1 = 0x00E0; //25uS*2;20KHz(1800) //25uS;40KHz() /* Set the Autoreload value */ TIM8->ARR = 1800 ; /* Set the Prescaler value */ TIM8->SC = 0; /* Generate an update event to reload the Prescaler and the repetition counter(only for TIM1 and TIM8) value immediatly */ TIM8->EGR = 0x0001; /* Reset the Output Polarity level */ TIM8->CCER = 0x00000000; /* Write to TIMx CR2 */ TIM8->CR2 = 0; /* Reset the Output Compare Mode Bits */ //PWMA,B,C,4WM mode2 TIM8->CCMR1 = 0x00007070; TIM8->CCMR2 = 0x00007070; //PWM5 TIM8->CCMR3 = 0x00000060; /* Set the Capture Compare Register value */ TIM8->CCR1 = 600; TIM8->CCR2 = 900; TIM8->CCR3 = 1500; TIM8->CCR4 = 1800; TIM8->CCR5 = 1740; /* Set the Output Compare Polarity */ TIM8->CCER |= 0x00011555; /* Reset the Output Compare Mode Bits */ //TIM8->CCMR1 &= 0xFFFFF7F7; //TIM8->CCMR2 &= 0xFFFFF7F7; //TIM8->CCMR3 &= 0xFFFFFFF7; TIM8->BDTR = 0x00028108;//???? TIM8->SR &=0xFF7E; TIM8->DIER = 0x0000; /* Enable the TIM Counter */ TIM8->CR1 &= 0xFFFE; TIM8->CR1 |= 0x0001; |
STM32F3 硬件I2C 驱动OLED 求助!!
STM32F303使用定时器触发双ADC常规同步采样模式
哪位大哥传下STM32F334 Nucleo的工程模板给我下
STM32F334 不能串口下载
关于STM32F334的HRTIM分辨率问题
STM32F303+LCD1602程序问题,不只为什么点不亮?
STM32F334的ADC使用问题
STM32F334 HRTIM形成移相全桥波形问题
有用过STM32F373VC的板子么 iic 例程不好使
STM32F3 ADC外部触发采样达不到7.2MSPS
评分
查看全部评分
寄存器代码看起来真辛苦,这里没看出配置问题来。
主要检查MODER/AFR寄存器的配置。
你也不妨检查确认下硬件线路。
或者用STM32CUBEMX配置个测试代码试试。
评分
查看全部评分
第一次发,见谅见谅。。。
检查过MODER和AFR寄存器,没有错。硬件连接也是好的。JTAG的端口有有两个被复用到TIM8输出,一个正常,就是JTDO没有输出。现在准备试一下直接用库函数。