EEM-465 Gömülü Sistemler
2022-2023 Güz Dönemi Ders 9
Genel Amaçlı Zamanlayıcılar
PWM sinyali üretme
#include "stm32f4xx.h"
int main(){
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN |
RCC_AHB1ENR_GPIOCEN;
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
GPIOA->MODER |= GPIO_MODER_MODER7_1;
GPIOC->MODER |= GPIO_MODER_MODER8_1;
GPIOA->AFR[0] |= GPIO_AFRL_AFSEL7_1;
GPIOC->AFR[1] |= GPIO_AFRH_AFSEL8_1;
TIM3->PSC=15;
TIM3->ARR=1000;
TIM3->CCR2=300;
TIM3->CCR3=600;
TIM3->CCMR1 |= TIM_CCMR1_OC2M_2 | TIM_CCMR1_OC2M_1;
TIM3->CCMR2 |= TIM_CCMR2_OC3M_2 | TIM_CCMR2_OC3M_1;
TIM3->CCER |= TIM_CCER_CC2E | TIM_CCER_CC3E;
TIM3->CR1 |= TIM_CR1_CEN;
while(1);
}