野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 12722|回复: 3

步进电机,不转,火哥看帖子~

[复制链接]
发表于 2013-6-15 18:28:23 | 显示全部楼层 |阅读模式
/**
  ******************************************************************************
  * @file    Project/STM32F10x_StdPeriph_Template/main.c
  * @author  MCD Application Team
  * @version V3.5.0
  * @date    08-April-2011
  * @brief   Main program body
  ******************************************************************************/
#include "stm32f10x.h"
#include "LED.h"
  unsigned int i;
unsigned char  F_Rotation[8]={0x80,0xc0,0x40,0x60,0x20,0x30,0x10,0x90};//正转表格   ????该怎么赋值
// unsigned char  B_Rotation[8]={0x90,0x80,0xc0,0x40,0x60,0x20,0x30,0x10};//反转表格
  int main(void)
{
/* LED 端口初始化 */
BJ_GPIO_Config();
/* 中断 端口初始化 */
EXTI_PE5_Config();
while (1)
{
   for(i=0;i<8;i++)
    {   
    GPIO_Write(GPIOB,F_Rotation[i]);  
  Delay(50);
  }   
}
}
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/




GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15 | GPIO_Pin_14 | GPIO_Pin_13 | GPIO_Pin_12;

用的是GPIO 15 14 13 12 口,该怎么使用这个GPIO_Write(GPIOB,F_Rotation[i]);


回复

使用道具 举报

 楼主| 发表于 2013-6-15 18:29:50 | 显示全部楼层
程序是用led流水灯修改的忽略其他的 ,就看
unsigned char  F_Rotation[8]={0x80,0xc0,0x40,0x60,0x20,0x30,0x10,0x90};//正转表格   ????该怎么赋值
和 GPIO_Write(GPIOB,F_Rotation[i]);  是否正确  
回复 支持 反对

使用道具 举报

发表于 2016-4-23 20:36:54 | 显示全部楼层
本帖最后由 fuhao123 于 2016-4-23 20:38 编辑

GPIO_Write(GPIOB,F_Rotation<<8); 应该是这样,我初学。因为gpio是16位,假设用0000 0000 0000 0000代替这16个引脚,而程序中引脚是 GPIO_Pin_15 | GPIO_Pin_14 | GPIO_Pin_13 | GPIO_Pin_12,也就是最左边的4个0000; 比如0x80化成2进制是1000 0000,左移8位,0000 0000 0000 0000就变成了1000 0000 0000 0000,对应引脚16位高电平。我也是初学,不知道这样理解是否正确,共同学习,共同进步。
回复 支持 反对

使用道具 举报

发表于 2016-4-23 21:45:09 | 显示全部楼层
你这个delay(50)是不是也太快了点啊
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-10-5 20:24 , Processed in 0.030479 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表