OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 12487|回复: 6

关于管脚定义

[复制链接]

1

主题

2

帖子

0

精华

新手入门

积分
26
金钱
26
注册时间
2013-8-10
在线时间
0 小时
发表于 2013-8-10 15:18:57 | 显示全部楼层 |阅读模式
请问原子哥,我用结构体定义管脚分配的,但是配置的时候输出管脚有用,但是输入却不起作用,程序如下:谢谢原子哥啊:
结构体定义(步进电机参数)







步进电机管脚分配




初始化的时候我打开了时钟,RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOG|RCC_APB2Periph_GPIOC,ENABLE);
                                                        for(i=0;i<BjMonitor_Number;i++)
                                                        {

                                                           } 




正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

1

主题

2

帖子

0

精华

新手入门

积分
26
金钱
26
注册时间
2013-8-10
在线时间
0 小时
 楼主| 发表于 2013-8-10 15:22:31 | 显示全部楼层
回复【楼主位】bitter:
---------------------------------
       这个是步进电机管脚定义,后面那个Opt是光耦开关管脚定义:
BjMonitor[0].EnaGpio = GPIOE; BjMonitor[0].EnaPin = GPIO_Pin_4;
BjMonitor[0].DirGpio = GPIOE; BjMonitor[0].DirPin = GPIO_Pin_3;
BjMonitor[0].PulGpio = GPIOE; BjMonitor[0].PulPin = GPIO_Pin_2;
// BjMonitor[0].OptGpio = GPIOG; BjMonitor[0].OptPin = GPIO_Pin_15;

BjMonitor[1].EnaGpio = GPIOF; BjMonitor[1].EnaPin = GPIO_Pin_0;
BjMonitor[1].DirGpio = GPIOE; BjMonitor[1].DirPin = GPIO_Pin_6;
BjMonitor[1].PulGpio = GPIOE; BjMonitor[1].PulPin = GPIO_Pin_5;
// BjMonitor[1].OptGpio = GPIOG; BjMonitor[1].OptPin = GPIO_Pin_14;

BjMonitor[2].EnaGpio = GPIOF; BjMonitor[2].EnaPin = GPIO_Pin_3;
BjMonitor[2].DirGpio = GPIOF; BjMonitor[2].DirPin = GPIO_Pin_2;
BjMonitor[2].PulGpio = GPIOF; BjMonitor[2].PulPin = GPIO_Pin_1;
// BjMonitor[2].OptGpio = GPIOG; BjMonitor[2].OptPin = GPIO_Pin_13;

BjMonitor[3].EnaGpio = GPIOF; BjMonitor[3].EnaPin = GPIO_Pin_6;
BjMonitor[3].DirGpio = GPIOF; BjMonitor[3].DirPin = GPIO_Pin_5;
BjMonitor[3].PulGpio = GPIOF; BjMonitor[3].PulPin = GPIO_Pin_4;
// BjMonitor[3].OptGpio = GPIOG; BjMonitor[3].OptPin = GPIO_Pin_12;

BjMonitor[4].EnaGpio = GPIOF; BjMonitor[4].EnaPin = GPIO_Pin_9;
BjMonitor[4].DirGpio= GPIOF; BjMonitor[4].DirPin = GPIO_Pin_8;
BjMonitor[4].PulGpio= GPIOF; BjMonitor[4].PulPin = GPIO_Pin_7;
// BjMonitor[4].OptGpio= GPIOG; BjMonitor[4].OptPin = GPIO_Pin_11;

BjMonitor[5].EnaGpio = GPIOC; BjMonitor[5].EnaPin = GPIO_Pin_1;
BjMonitor[5].DirGpio = GPIOC; BjMonitor[5].DirPin = GPIO_Pin_0;
BjMonitor[5].PulGpio = GPIOF; BjMonitor[5].PulPin = GPIO_Pin_10;
// BjMonitor[5].OptGpio = GPIOG; BjMonitor[5].OptPin = GPIO_Pin_10;

BjMonitor[6].EnaGpio = GPIOA; BjMonitor[6].EnaPin = GPIO_Pin_1;
BjMonitor[6].DirGpio = GPIOC; BjMonitor[6].DirPin = GPIO_Pin_3;
BjMonitor[6].PulGpio = GPIOC; BjMonitor[6].PulPin = GPIO_Pin_2;
// BjMonitor[6].OptGpio = GPIOG; BjMonitor[6].OptPin = GPIO_Pin_9;

BjMonitor[7].EnaGpio = GPIOA; BjMonitor[7].EnaPin = GPIO_Pin_6;
BjMonitor[7].DirGpio = GPIOA; BjMonitor[7].DirPin = GPIO_Pin_5;
BjMonitor[7].PulGpio = GPIOA; BjMonitor[7].PulPin = GPIO_Pin_4;
// BjMonitor[7].OptGpio = GPIOD; BjMonitor[7].OptPin = GPIO_Pin_7;

BjMonitor[8].EnaGpio = GPIOC; BjMonitor[8].EnaPin = GPIO_Pin_5;
BjMonitor[8].DirGpio = GPIOC; BjMonitor[8].DirPin = GPIO_Pin_4;
BjMonitor[8].PulGpio = GPIOA; BjMonitor[8].PulPin = GPIO_Pin_7;
// BjMonitor[8].OptGpio = GPIOD; BjMonitor[8].OptPin = GPIO_Pin_6;

BjMonitor[9].EnaGpio = GPIOC; BjMonitor[9].EnaPin = GPIO_Pin_13;
BjMonitor[9].DirGpio = GPIOB; BjMonitor[9].DirPin = GPIO_Pin_1;
BjMonitor[9].PulGpio = GPIOB; BjMonitor[9].PulPin = GPIO_Pin_0;
// BjMonitor[9].OptGpio = GPIOD; BjMonitor[9].OptPin = GPIO_Pin_5;

BjMonitor[10].EnaGpio = GPIOF; BjMonitor[10].EnaPin = GPIO_Pin_13;
BjMonitor[10].DirGpio = GPIOF; BjMonitor[10].DirPin = GPIO_Pin_12;
BjMonitor[10].PulGpio = GPIOF; BjMonitor[10].PulPin = GPIO_Pin_11;
// BjMonitor[10].OptGpio = GPIOD; BjMonitor[10].OptPin = GPIO_Pin_4;

BjMonitor[11].EnaGpio = GPIOG; BjMonitor[11].EnaPin = GPIO_Pin_0;
BjMonitor[11].DirGpio = GPIOF; BjMonitor[11].DirPin = GPIO_Pin_15;
BjMonitor[11].PulGpio = GPIOF; BjMonitor[11].PulPin = GPIO_Pin_14;
// BjMonitor[11].OptGpio = GPIOD; BjMonitor[11].OptPin = GPIO_Pin_3;

BjMonitor[12].EnaGpio = GPIOE; BjMonitor[12].EnaPin = GPIO_Pin_8;
BjMonitor[12].DirGpio = GPIOE; BjMonitor[12].DirPin = GPIO_Pin_7;
BjMonitor[12].PulGpio = GPIOG; BjMonitor[12].PulPin = GPIO_Pin_1;
// BjMonitor[12].OptGpio = GPIOD; BjMonitor[12].OptPin = GPIO_Pin_2;

BjMonitor[13].EnaGpio = GPIOE; BjMonitor[13].EnaPin = GPIO_Pin_11;
BjMonitor[13].DirGpio = GPIOE; BjMonitor[13].DirPin = GPIO_Pin_10;
BjMonitor[13].PulGpio = GPIOE; BjMonitor[13].PulPin = GPIO_Pin_9;
// BjMonitor[13].OptGpio = GPIOD; BjMonitor[13].OptPin = GPIO_Pin_1;

BjMonitor[14].EnaGpio = GPIOE; BjMonitor[14].EnaPin = GPIO_Pin_14;
BjMonitor[14].DirGpio = GPIOE; BjMonitor[14].DirPin = GPIO_Pin_13;
BjMonitor[14].PulGpio = GPIOE; BjMonitor[14].PulPin = GPIO_Pin_12;
// BjMonitor[14].OptGpio = GPIOD; BjMonitor[14].OptPin = GPIO_Pin_0;

BjMonitor[15].EnaGpio = GPIOB; BjMonitor[15].EnaPin = GPIO_Pin_11;
BjMonitor[15].DirGpio = GPIOB; BjMonitor[15].DirPin = GPIO_Pin_10;
BjMonitor[15].PulGpio = GPIOE; BjMonitor[15].PulPin = GPIO_Pin_15;
// BjMonitor[15].OptGpio = GPIOC; BjMonitor[15].OptPin = GPIO_Pin_12;


 void Monitor_GPIO_Init(void)
{  
u8 i;
GPIO_InitTypeDef  GPIO_InitStructure;
Bj_Init();
for(i=0; i< BJMONITOR_NUMBER;i++)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE,ENABLE);
GPIO_InitStructure.GPIO_Pin = BjMonitor.PulPin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;   //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(BjMonitor.PulGpio, &GPIO_InitStructure);
GPIO_SetBits(BjMonitor.PulGpio,BjMonitor.PulPin);

//设置dir 引脚
GPIO_InitStructure.GPIO_Pin = BjMonitor.DirPin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;   //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(BjMonitor.DirGpio, &GPIO_InitStructure);
GPIO_SetBits(BjMonitor.DirGpio,BjMonitor.DirPin);

//设置Ena 引脚
GPIO_InitStructure.GPIO_Pin = BjMonitor.EnaPin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;   //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(BjMonitor.EnaGpio, &GPIO_InitStructure);
GPIO_SetBits(BjMonitor.EnaGpio,BjMonitor.EnaPin);

//设置光电开关检测引脚
GPIO_InitStructure.GPIO_Pin = BjMonitor.OptPin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;   //浮空输入
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_Init(BjMonitor.OptGpio, &GPIO_InitStructure);
}

为什么光耦用不了,但是控制电机部分的输出有用,谢谢原子哥 啊
回复 支持 反对

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165540
金钱
165540
注册时间
2010-12-1
在线时间
2117 小时
发表于 2013-8-10 17:49:09 | 显示全部楼层
回复【2楼】bitter:
---------------------------------
你这好麻烦啊,呵呵.
直接仿真器跟踪,然后进入库函数里面,看操作是不是符合预期,结合寄存器状态,分析问题.
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复 支持 反对

使用道具 举报

18

主题

102

帖子

0

精华

初级会员

Rank: 2

积分
194
金钱
194
注册时间
2012-12-2
在线时间
0 小时
发表于 2013-8-10 19:43:48 | 显示全部楼层
回复【3楼】正点原子:
---------------------------------
原子 哥  TFT液晶 可以用8个数据线 把一个16位数据分两次写吗?也就是说 只用TFT的8个数据线 高8为的数据线不用
回复 支持 反对

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165540
金钱
165540
注册时间
2010-12-1
在线时间
2117 小时
发表于 2013-8-10 20:26:51 | 显示全部楼层
回复【4楼】电子好学者:
---------------------------------
8位的TFT就可以,16位的TFT不行.
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复 支持 反对

使用道具 举报

18

主题

102

帖子

0

精华

初级会员

Rank: 2

积分
194
金钱
194
注册时间
2012-12-2
在线时间
0 小时
发表于 2013-8-11 08:26:08 | 显示全部楼层
回复【5楼】正点原子:
---------------------------------
你们 开发板 配套的液晶 是多少位的呢?
回复 支持 反对

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165540
金钱
165540
注册时间
2010-12-1
在线时间
2117 小时
发表于 2013-8-11 10:00:36 | 显示全部楼层
16
回复 支持 反对

使用道具 举报

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

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-7-15 05:40

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

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