Stm32f7 Disco with pwm signal

0 nhận xét

Summary:

今回,Stm32cubemxを使って,pwm signal のoutputをやってみます.
1. Clock setting
RCCのhigh speed clockを有効にし,clock configurationで216Mhz にする.
2. Timer setting
PA_8 (timer 1 channel 1)で pwm signal を出力にする.
At Tim1
2.1Clock source を internal clock にする.
2.2 Channel 1を PWM generation CH1にする.
3.  Timer configuration 
Counter period : 65535 に設定する.

4. Source 生成・ Insert Program
 Src/main.c でsource 追加

int main(void)
{

  HAL_Init();

  /* Configure the system clock */
  SystemClock_Config();

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_TIM1_Init();
 HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_1);
  while (1)
  {
        for(i=0;i<65535;i++){
           TIM1->CCR1=i; // duty=TIM1->CRR1/ Period  (65535)
           HAL_Delay(1);
       }

  }
}


Facebook Comments
Blogger Comments
Share knowledge

Copyright © 2016 - Share knowledge ®