首先,向所有阅读此文档的人致以帮助。
我有一个小项目。用STM32F303构建的3x3x3 LED Cupe。 我试图让TIM2与三个通道一起工作,但是..什么都没有发生。
这是代码:
#include "stm32f3xx.h"
#include "stm32f3xx_nucleo.h"
int main(void){
RCC->AHBENR |= RCC_AHBENR_GPIOAEN;
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
GPIOA->MODER |= 0b10; //PA0
GPIOA->MODER |= 0b10 << 2; //PA1
GPIOA->MODER |= 0b10 << 4; //PA2
GPIOA->AFR[0] |= 0b0001;
GPIOA->AFR[0] |= 0b0001 << 4;
GPIOA->AFR[0] |= 0b0001 << 8;
TIM2->CCMR1 = (0b0110 << 4) | (0b0110 << 12);
TIM2->CCMR2 = 0b0110 << 4;
TIM2->CCER = TIM_CCER_CC1E;
TIM2->CCER = TIM_CCER_CC2E;
TIM2->CCER = TIM_CCER_CC3E;
TIM2->PSC = 7999;
TIM2->ARR = 999;
TIM2->CCR1 = 99;
TIM2->CCR2 = 399;
TIM2->CCR3 = 699;
TIM2->CR1 = TIM_CR1_CEN;
while (1)
{
;
}
有什么想法吗?
答案 0 :(得分:1)
似乎您错过了一些东西。
希望如此。