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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3996|回復: 2
打印 上一主題 下一主題
收起左側

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)


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復

使用道具 舉報

沙發
ID:436417 發表于 2018-12-3 14:41 | 只看該作者
收藏
回復

使用道具 舉報

板凳
ID:110942 發表于 2018-12-3 21:02 | 只看該作者
好,不錯收藏了!
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 久久久久久久一区二区三区 | 天天操天天天 | 精品日韩一区二区三区 | 国产农村妇女毛片精品久久麻豆 | 蜜桃一区二区三区 | 色性av | 久久婷婷av | 欧美一区二区三区在线 | a视频在线观看 | 色小姐综合网 | 五月激情综合网 | www免费视频 | 亚洲欧美另类在线观看 | www.精品国产 | 午夜理伦三级理论三级在线观看 | 中文字字幕一区二区三区四区五区 | 国产精品久久九九 | 欧美三级三级三级爽爽爽 | 另类 综合 日韩 欧美 亚洲 | av夜夜操 | aacc678成免费人电影网站 | 久草在线 | 中文字幕在线观 | 亚洲国产aⅴ成人精品无吗 国产精品永久在线观看 | 国产日韩中文字幕 | 亚洲啪啪 | 亚洲色图网址 | 国产成人在线一区二区 | 亚洲欧美中文日韩在线v日本 | 日韩亚洲欧美综合 | 中文字幕日韩欧美 | av喷水 | 在线成人| 日韩精品一区二区三区中文在线 | 精品福利在线 | 亚洲欧美视频 | 欧美福利网站 | 精品亚洲视频在线 | 成人黄页在线观看 | 亚洲网站在线播放 | 久久精品中文字幕 |