Advertisement
Guest User

Untitled

a guest
Jun 26th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int main()
  2. {
  3.  
  4. lcd_Init();
  5. //GPIO_CONFIG();
  6. ADC_CONFIG();
  7.  
  8. //GPIO_Config(GPIOD,GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15,GPIO_Mode_OUT);
  9. //GPIO_Config(GPIOA,GPIO_Pin_0,GPIO_Mode_IN);
  10. //GPIO_Config(GPIOD,GPIO_Pin_13,GPIO_Mode_OUT);
  11. //GPIO_Config(GPIOD,GPIO_Pin_14,GPIO_Mode_OUT);
  12. //GPIO_Config(GPIOD,GPIO_Pin_15,GPIO_Mode_OUT);
  13. lcd_Clear();
  14. lcd_Goto(0,0);
  15. printf("Le Hai Anh");
  16. lcd_Goto(1,0);
  17. printf("11119108");
  18. Delay(5000000);
  19. lcd_Clear();
  20.  
  21. while(1)
  22. {
  23. adc = READ_ADC();
  24. t=(float)(adc*5*100/4095);
  25. lcd_Goto(0,0);
  26. printf("Temp = %f",t);
  27.  
  28. }
  29. }
  30.  
  31. void ADC_CONFIG(void)
  32. {
  33. RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA,ENABLE);
  34. RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1,ENABLE);
  35.  
  36. PINinit.GPIO_Pin = GPIO_Pin_0;
  37. PINinit.GPIO_Mode = GPIO_Mode_AIN;
  38. PINinit.GPIO_PuPd = GPIO_PuPd_NOPULL;
  39. GPIO_Init(GPIOA,&PINinit);
  40.  
  41. ADC_DeInit();
  42.  
  43.  
  44. ADCinit.ADC_ContinuousConvMode = ENABLE;
  45. ADCinit.ADC_DataAlign = ADC_DataAlign_Right;
  46. ADCinit.ADC_ExternalTrigConv = DISABLE;
  47. ADCinit.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
  48. ADCinit.ADC_NbrOfConversion = 1;
  49. ADCinit.ADC_ScanConvMode = DISABLE;
  50. ADCinit.ADC_Resolution = ADC_Resolution_12b;
  51.  
  52. ADC_Init(ADC1,&ADCinit);
  53.  
  54.  
  55. ADC_RegularChannelConfig(ADC1,ADC_Channel_0,1,ADC_SampleTime_144Cycles);
  56. ADC_Cmd(ADC1,ENABLE);
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement