标题: stm32f103中断查询AD转换结果的程序源码 [打印本页]

作者: 316998491@    时间: 2018-8-9 10:55
标题: stm32f103中断查询AD转换结果的程序源码
stm32f103中断查询AD转换结果

单片机源程序如下:
  1. /****************************************************************************
  2. * Copyright (C), 2013 奋斗嵌入式工作室
  3. *
  4. * 本例程在 奋斗版STM32开发板V2,V2.1,V3,V5及MINI上调试通过           
  5. *
  6. * 文件名: main.c
  7. * 内容简述:       
  8. *      
  9. *        演示的是3个蓝色LED(LED1-LED3) 轮流闪烁
  10.    
  11.         定义:       
  12.         LED1-LED3 ---V6——V8
  13.         V6----- PB5-LED1
  14.         V7----- PD6-LED2(仅V2,V2.1 V3  V5板)
  15.         V8----- PD3-LED3(仅V2,V2.1 V3  V5板)
  16.    
  17.         基于MDK版本:        3.8
  18.         基于官方外设库版本: 3.5
  19. *
  20. * 文件历史:
  21. * 版本号  日期       作者    说明
  22. * v0.2    2011-7-28 sun68  创建该文件
  23. *
  24. */
  25. /* Includes peripheral official head ------------------------------------------------------------------*/
  26. #include "stm32f10x.h"
  27. #include "stm32f10x_exti.h"
  28. #include "stm32f10x_rcc.h"
  29. #include "stm32f10x_it.h"
  30. //#include "misc.h"
  31. /* Includes  peripheral user define head ----------------------------------------------------------------------*/
  32. #include "stm32f10x_bitband.h"
  33. #include "exti.h"
  34. #include "nvic.h"
  35. #include "systick.h"
  36. #include "gpio_config.h"
  37. #include "adc1.h"
  38. /* Includes function ----------------------------------------------------------------------*/
  39. /* Includes user head ----------------------------------------------------------------------*/
  40. #include "led.h"
  41. #include "key.h"
  42. #include "ir_recive.h"
  43. #include "bat_lowpower.h"
  44. volatile uint16_t DataValue;
  45. /* Includes function ----------------------------------------------------------------------*/
  46. void RCC_Configuration(void);
  47. void Delay(__IO uint32_t nCount);
  48. /****************************************************************************
  49. * 名    称:int main(void)
  50. * 功    能:主函数
  51. * 入口参数:无
  52. * 出口参数:无
  53. * 说    明:
  54. * 调用方法:无
  55. ****************************************************************************/
  56. int main(void)
  57. {
  58.         RCC_Configuration( );                                   //系统时钟配置
  59.         LED_Config( );                                                        //LED控制配置
  60.         GPOIA_Config( );
  61.         IR_GPIO_Config( );
  62.         Key_GPIO_Config( );
  63.         ADC1_Gpio_Config( );

  64.         NVIC_Configuration( );
  65.         Exti_Configuration( );
  66.         ADC1_Configuration( );
  67. //        if ( SysTick_Config( 72000 ) )                    //时钟节拍中断时1ms一次  用于定时
  68. //        {
  69. //                /* Capture error */
  70. //                while (1);
  71. //        }
  72.         if ( SysTick_Config( 72000 ) )                    //时钟节拍中断时100us一次  用于定时
  73.         {
  74.                 /* Capture error */
  75.                 while (1);
  76.         }


  77.         while ( 1 )
  78.         {
  79.                 if ( f_1ms )
  80.                 {
  81.                         f_1ms = 0;
  82.                         rx_ir( );
  83.                         ir_rx_fun( );
  84.                         key_scan( );
  85.                         blue_fliker( );
  86.                 //        BAT_lowpower( );
  87.                         ADC_SoftwareStartConvCmd(ADC1, ENABLE);
  88.                 }
  89.        
  90.         }
  91. }

  92. /****************************************************************************
  93. * 名    称:void RCC_Configuration(void)
  94. * 功    能:系统时钟配置为72MHZ
  95. * 入口参数:无
  96. * 出口参数:无
  97. * 说    明:
  98. * 调用方法:无
  99. ****************************************************************************/
  100. void RCC_Configuration(void)
  101. {   
  102.   SystemInit();
  103. }

  104. /****************************************************************************
  105. * 名    称:void Delay(__IO uint32_t nCount)
  106. * 功    能:延时函数
  107. * 入口参数:无
  108. * 出口参数:无
  109. * 说    明:
  110. * 调用方法:无
  111. ****************************************************************************/
  112. void Delay(__IO uint32_t nCount)
  113. {
  114.    for(; nCount != 0; nCount--);
  115. }


  116. /******************* (C) COPYRIGHT 2013 奋斗STM32 *****END OF FILE****/
复制代码

所有资料51hei提供下载:
STM32奋斗板-ADC中断查询结果.rar (291.67 KB, 下载次数: 23)







欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1