Advertisement
Guest User

MAIN

a guest
Apr 24th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. #include "functions.h"
  2.  
  3.  
  4. volatile uint16_t adcValue;
  5.  
  6. int main(void)
  7. {
  8.     SystemInit();
  9.  
  10.     GPIO_Leds_Init();
  11.     TIM_Init();
  12.     PWM_Init();
  13.     ADC_MyInit();
  14.  
  15.  
  16.     while(1)
  17.     {
  18.         TIM4->CCR1 = 2* adcValue;
  19.     }
  20. }
  21.  
  22. void ADC_IRQHandler(void){
  23.     if(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == SET){
  24.         adcValue = ADC1 -> DR;
  25.     }
  26.     ADC_ClearFlag(ADC1, ADC_FLAG_EOC);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement