LED won't blink (Timer with PWM)
Hi could somebody please help me with this: i am a beginner ,i have set the Timer_init and Gpio_init with bare Metal
i'm working in STM32F429ZIT and i'm aiming to control GPIO pins PG13 and PG14 using the PWM channels with two channel each for every LED
but the LEDs on PG13 and PG14 aren’t blinking
i debugged the Leds, they are working correctly but when it comes to use PWM nothing appears
here's the code :
#include "stm32f4xx.h"
void GPIO_Config(void);
void TIM_Config(void);
int main(void)
{
GPIO_Config();
TIM_Config();
while (1)
{
}
}
void GPIO_Config(void)
{
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOGEN;
GPIOG->MODER &= ~((0x3 << (13 * 2)) | (0x3 << (14 * 2)));
GPIOG->MODER |= ((0x1 << (13 * 2)) | (0x1 << (14 * 2)));
GPIOG->AFR[1] |= ((0x2 << (4 * (13 - 8))) | (0x2 << (4 * (14 - 8))));
}
void TIM_Config(void)
{
RCC->APB1ENR |= RCC_APB1ENR_TIM4EN;
TIM4->PSC = 8400 - 1;
TIM4->ARR = 1000 - 1;
TIM4->CCMR1 |= (0x6 << 4);
TIM4->CCMR1 |= (1 << 3);
TIM4->CCER |= TIM_CCER_CC1E;
TIM4->CCR1 = 300;
TIM4->CCMR1 |= (0x6 << 12);
TIM4->CCMR1 |= (1 << 11);
TIM4->CCER |= TIM_CCER_CC2E;
TIM4->CCR2 = 700;
TIM4->CR1 |= TIM_CR1_CEN;
}
