0

I'm programming a board and want a PWM signal to appear on a pin to drive a LED. I'm using a STM32 NUCLEO-F207ZG board, and only low-level register programming. It is not working.

I've looked into the manual, datasheet and application note. Also some Google searches have been done.

//Enable timer 1 clock: RCC->APB2ENR |= BIT0;

//Output mode on PWM
TIM1->CCMR1 |= BIT5 | BIT6;

//Period:
TIM1->ARR = 0x0000FFFF;

//Duty cycle:
TIM1->CCR1 = 0x00007FFF;

//Enable preload
TIM1->CCMR1 |= BIT3;
TIM1->CR1 |= BIT7;

//Enable CC1 output
TIM1->CCER |= BIT0;

//Enable timer
TIM1->CR1 |= BIT0;

//Enable GPIOE clock
RCC->AHB1ENR |= BIT4;

//Alternate function mode voor pin PE_9
GPIOE->MODER |= BIT19;
GPIOE->AFR[1] |= BIT4;

I expect a PWM signal on pin D6 (PE_9), to drive a LED. But the LED doesn't seem to do anything.

4

1 に答える 1