久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

標題: STM32F103xx微控制器驅動步進電機源碼 [打印本頁]

作者: 上帝不吭聲    時間: 2018-5-8 10:56
標題: STM32F103xx微控制器驅動步進電機源碼
官方庫文件--使用中容量STM32F103xx微控制器驅動步進電機



單片機源程序如下:
  1. /**
  2.   ******************************************************************************
  3.   * @file FullHalfStepMode/src/main.c
  4.   * @author  MCD Application Team
  5.   * @version  V2.0.0
  6.   * @date  04/27/2009
  7.   * @brief  Main program body
  8.   ******************************************************************************
  9.   * @copy
  10.   *
  11.   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  12.   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  13.   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  14.   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  15.   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  16.   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  17.   *
  18.   * <h2><center>© COPYRIGHT 2009 STMicroelectronics</center></h2>
  19.   */

  20. /* Includes ------------------------------------------------------------------*/
  21. #include "stm32f10x.h"
  22. #include "StepperMotor.h"
  23. #include <stdio.h>



  24. /** @addtogroup FullHalfStepMode
  25.   * @{
  26.   */


  27. /* Private typedef -----------------------------------------------------------*/
  28.   /* Private define ------------------------------------------------------------*/
  29. /* -------------------- Stepper modes entering function ---------------- */
  30. /******* Define the Rotation Direction *******/
  31. #define RotationDirection_CW
  32. //#define RotationDirection_CCW

  33. /******* Define the Step Mode *********/
  34. #define Half_Step
  35. //#define Full_Step

  36. /******* Define the Decay Mode ********/
  37. //#define ControlSlow_Current
  38. #define ControlFast_Current

  39. /* Private macro -------------------------------------------------------------*/
  40. /* Private variables ---------------------------------------------------------*/

  41. ErrorStatus HSEStartUpStatus;

  42. /* Private function prototypes -----------------------------------------------*/
  43. void RCC_Configuration(void);
  44. void NVIC_Configuration(void);
  45.    
  46. /* Private functions ---------------------------------------------------------*/



  47. /**
  48.   * @brief  Main program
  49.   * @param  None
  50.   * @retval : None
  51.   */
  52. int main(void)
  53. {

  54.   /* System Clocks Configuration */
  55.   RCC_Configuration();
  56.   
  57.   /* NVIC Configuration */
  58.   NVIC_Configuration();
  59.   
  60.   /* Activate the driver */
  61.   Stepper_Cmd(ENABLE);
  62.   
  63.   /* Driver control pin configuration */
  64.   Stepper_PinControlConfig();
  65.   
  66.   /* Disable the initialization of the driver */
  67.   Stepper_ResetDisable();
  68.       
  69.   /* -----------Modes selection: Rotation direction, Step mode, Decay mode---------------*/
  70. #ifdef RotationDirection_CW
  71.   Stepper_SetRotationDirection(Stepper_RotationDirection_CW);
  72. #endif /* RotationDirection_CW */

  73. #ifdef RotationDirection_CCW
  74.   Stepper_SetRotationDirection(Stepper_RotationDirection_CCW);
  75. #endif /* RotationDirection_CCW */
  76.   
  77. #ifdef Half_Step
  78.   Stepper_SelectMode(Stepper_Half);
  79. #endif  /* Half_Step */
  80.   
  81. #ifdef Full_Step
  82.   Stepper_SelectMode(Stepper_Full);
  83. #endif  /* Full_Step */

  84. #ifdef ControlSlow_Current
  85.   Stepper_SetControlMode(Stepper_ControlSlow);
  86. #endif  /* ControlSlow_Current */  

  87. #ifdef ControlFast_Current
  88.   Stepper_SetControlMode(Stepper_ControlFast);
  89. #endif   /* ControlFast_Current */
  90.   
  91.   
  92.   /* Start the stepper motor */   
  93.   Stepper_Start(ENABLE);
  94.   
  95.   /* Peripherals configuration */
  96.   Stepper_Init();
  97.   
  98.   while (1)
  99.   {
  100.   }   
  101. }



  102. /**
  103.   * @brief  Configures the different system clocks.
  104.   * @param  None
  105.   * @retval : None
  106.   */
  107. void RCC_Configuration(void)
  108. {   
  109.   /* RCC system reset(for debug purpose) */
  110.   RCC_DeInit();

  111.   /* Enable HSE */
  112.   RCC_HSEConfig(RCC_HSE_ON);

  113.   /* Wait till HSE is ready */
  114.   HSEStartUpStatus = RCC_WaitForHSEStartUp();

  115.   if(HSEStartUpStatus == SUCCESS)
  116.   {
  117.     /* Enable Prefetch Buffer */
  118.     FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

  119.     /* Flash 2 wait state */
  120.     FLASH_SetLatency(FLASH_Latency_2);

  121.     /* HCLK = SYSCLK */
  122.     RCC_HCLKConfig(RCC_SYSCLK_Div1);
  123.   
  124.     /* PCLK2 = HCLK */
  125.     RCC_PCLK2Config(RCC_HCLK_Div1);

  126.     /* PCLK1 = HCLK/2 */
  127.     RCC_PCLK1Config(RCC_HCLK_Div2);

  128.     /* PLLCLK = 8MHz * 9 = 72 MHz */
  129.     RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);

  130.     /* Enable PLL */
  131.     RCC_PLLCmd(ENABLE);

  132.     /* Wait till PLL is ready */
  133.     while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
  134.     {
  135.     }
  136.    
  137.     /* Select PLL as system clock source */
  138.     RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

  139.     /* Wait till PLL is used as system clock source */
  140.     while(RCC_GetSYSCLKSource() != 0x08)
  141.     {
  142.     }
  143.   }

  144. }

  145. /**
  146.   * @brief  Configure the nested vectored interrupt controller.
  147.   * @param  None
  148.   * @retval : None
  149.   */
  150. void NVIC_Configuration(void)
  151. {


  152.   NVIC_SetPriorityGrouping(7); /* 0 bits for pre-emption priority 4 bits for
  153. subpriority*/
  154.   NVIC_SetPriority(DMA1_Channel2_IRQn, 0x01); /* 0x01 = 0x0 << 3 | (0x1 & 0x7), prority
  155. is 0x01 << 4 */
  156. NVIC_EnableIRQ(DMA1_Channel2_IRQn);

  157.   
  158. }

  159. #ifdef  USE_FULL_ASSERT


  160. ……………………

  161. …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼

所有資料51hei提供下載:
官方庫文件--使用中容量STM32F103xx微控制器驅動步進電機.zip (1.21 MB, 下載次數: 66)



作者: wangdunyuan1    時間: 2018-12-3 14:41
收藏
作者: byoo    時間: 2018-12-3 21:02
好,不錯收藏了!




歡迎光臨 (http://www.zg4o1577.cn/bbs/) Powered by Discuz! X3.1
主站蜘蛛池模板: 91免费版在线观看 | 日韩一区在线播放 | 精品欧美乱码久久久久久 | 国产精品毛片av一区 | 国产精品日韩一区二区 | 国产精品毛片一区二区三区 | 欧美精品一区二区三区蜜桃视频 | 国产精品久久久久久久久久久久 | 亚洲精品自在在线观看 | 欧美中文 | 99在线播放 | 久久国产精品免费 | 久久成人国产精品 | 性色av一区二区三区 | 五月天天丁香婷婷在线中 | 色综合天天天天做夜夜夜夜做 | 国产成人一区二区三区电影 | 91视视频在线观看入口直接观看 | 欧美一区二区在线观看 | 999精品视频 | 国产精品成人国产乱 | 日本超碰在线 | 午夜视频网站 | 国产一区二区三区在线 | 日本欧美黄色片 | www.中文字幕.com | 射欧美 | 国产成人在线视频播放 | 亚洲 欧美 激情 另类 校园 | 日韩精品成人av | 日韩欧美亚洲 | 黑人巨大精品欧美一区二区一视频 | 国产91在线 | 欧美 | 国产一区欧美 | 国产午夜精品久久久久免费视高清 | 黄色av网站在线观看 | 亚洲成人自拍 | 综合色导航| 一区二区三区免费 | 91看片在线观看 | 国产精品成人久久久久a级 久久蜜桃av一区二区天堂 |