硬汉嵌入式论坛

 找回密码
 立即注册
查看: 13695|回复: 10
收起左侧

[例程下载] STM32F4学习笔记一(F1和F4的GPIO)

[复制链接]

20

主题

55

回帖

20

积分

初级会员

积分
20
发表于 2012-12-13 21:31:08 | 显示全部楼层 |阅读模式
F1和F4的GPIO的结构决定了他们使用上的区别,我先贴出来。
F1的GPIO
F1.jpg
F4的GPIO
F4.jpg
上面画红线的地方不同,决定了他们使用的区别, 所以F4多了一个GPIOx_OTYPER寄存器
输出类型寄存器
F1的GPIO功能
F11.jpg
F4的GPIO
F44.jpg
天天向上
回复

使用道具 举报

20

主题

55

回帖

20

积分

初级会员

积分
20
 楼主| 发表于 2012-12-14 14:31:08 | 显示全部楼层
GPIO有四种工作模式,输入,输出,模拟,复用。
这里主要说一下输出,复用类似。
从上面的图可以看出输出也可以配置弱上拉 弱下来,这个不知道是干什么用的,暂时没用过。
F444.jpg
天天向上
回复

使用道具 举报

20

主题

55

回帖

20

积分

初级会员

积分
20
 楼主| 发表于 2012-12-14 14:38:32 | 显示全部楼层
F1和F4的模拟输入是高阻抗的,这个我一直没有看出来,有看懂的同学帮忙看看
f4444.jpg
天天向上
回复

使用道具 举报

20

主题

55

回帖

20

积分

初级会员

积分
20
 楼主| 发表于 2012-12-14 15:14:39 | 显示全部楼层
===================================================================
  *                                 How to use this driver
  *          ===================================================================      
  *           1. Enable the GPIO AHB clock using the following function
  *                RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOx, ENABLE);
  *            
  *           2. Configure the GPIO pin(s) using GPIO_Init()
  *              Four possible configuration are available for each pin:
  *                - Input: Floating, Pull-up, Pull-down.
  *                - Output: Push-Pull (Pull-up, Pull-down or no Pull)
  *                          Open Drain (Pull-up, Pull-down or no Pull).
  *                  In output mode, the speed is configurable: 2 MHz, 25 MHz,
  *                  50 MHz or 100 MHz.
  *                - Alternate Function: Push-Pull (Pull-up, Pull-down or no Pull)
  *                                      Open Drain (Pull-up, Pull-down or no Pull).
  *                - Analog: required mode when a pin is to be used as ADC channel
  *                          or DAC output.
  *
  *          3- Peripherals alternate function:
  *              - For ADC and DAC, configure the desired pin in analog mode using
  *                  GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AN;
  *              - For other peripherals (TIM, USART...):
  *                 - Connect the pin to the desired peripherals' Alternate
  *                   Function (AF) using GPIO_PinAFConfig() function
  *                 - Configure the desired pin in alternate function mode using
  *                   GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF
  *                 - Select the type, pull-up/pull-down and output speed via
  *                   GPIO_PuPd, GPIO_OType and GPIO_Speed members
  *                 - Call GPIO_Init() function
  *        
  *          4. To get the level of a pin configured in input mode use GPIO_ReadInputDataBit()
  *         
  *          5. To set/reset the level of a pin configured in output mode use
  *             GPIO_SetBits()/GPIO_ResetBits()
  *               
  *          6. During and just after reset, the alternate functions are not
  *             active and the GPIO pins are configured in input floating mode
  *             (except JTAG pins).
  *
  *          7. The LSE oscillator pins OSC32_IN and OSC32_OUT can be used as
  *             general-purpose (PC14 and PC15, respectively) when the LSE
  *             oscillator is off. The LSE has priority over the GPIO function.
  *
  *          8. The HSE oscillator pins OSC_IN/OSC_OUT can be used as
  *             general-purpose PH0 and PH1, respectively, when the HSE
  *             oscillator is off. The HSE has priority over the GPIO function.
  *            
  *  @endverbatim        
  *
  ******************************************************************************
天天向上
回复

使用道具 举报

20

主题

55

回帖

20

积分

初级会员

积分
20
 楼主| 发表于 2012-12-14 15:33:05 | 显示全部楼层
1. 使能GPIO AHB时钟
   
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOx, ENABLE);
2. 使用
GPIO_Init()配置GPIO引脚
    (1)
Input: Floating, Pull-up, Pull-down.
    (2)
Output: Push-Pull (Pull-up, Pull-down or no Pull)
                        
Open Drain (Pull-up, Pull-down or no Pull)
              输出模式,速度可以配置成
2 MHz, 25 MHz, 50 MHz or 100 MHz.
3. 外设复用功能
             a. 对于ADC和DAC,
GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AN;
             b.
Connect the pin to the desired peripherals' Alternate
                  Function (AF) using GPIO_PinAFConfig() function
                - Configure the desired pin in alternate function mode using
                  GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF
                - Select the type, pull-up/pull-down and output speed via
                  GPIO_PuPd, GPIO_OType and GPIO_Speed members
                - Call GPIO_Init() function
4. 读取引脚的数据使用
GPIO_ReadInputDataBit()
5. 置位和复位,使用
GPIO_SetBits()/GPIO_ResetBits();
6. 除了JATG引脚,系统复位以后,默认的引脚状态是input floating mode
7. LSE的晶振引脚可以作为通用IO使用,但作为晶振引脚的优先级高于作为普通IO

8. HSE的晶振引脚可以作为通用IO使用,但作为晶振引脚的优先级高于作为普通IO
天天向上
回复

使用道具 举报

1

主题

2

回帖

1

积分

新手上路

积分
1
发表于 2013-1-31 08:42:47 | 显示全部楼层
收藏学习了。
回复

使用道具 举报

0

主题

3

回帖

0

积分

新手上路

http://www.luxresorts.com/cn/

积分
0
发表于 2013-6-17 15:54:28 | 显示全部楼层
我想说,楼主的水平真的好高哦, 我什么时候能有你这个水平啊
回复

使用道具 举报

0

主题

1

回帖

0

积分

新手上路

积分
0
QQ
发表于 2013-7-18 16:18:27 | 显示全部楼层
[s:151]
回复

使用道具 举报

0

主题

5

回帖

5

积分

新手上路

积分
5
发表于 2013-7-25 09:12:45 | 显示全部楼层
顶,支持个~~~~~
学无止境。
回复

使用道具 举报

1

主题

33

回帖

36

积分

新手上路

积分
36
发表于 2016-1-5 16:45:33 | 显示全部楼层

回 stm32f4 的帖子

stm32f4:
1. 使能GPIO AHB时钟
   
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOx, ENABLE);
2. 使用
GPIO_Init()配置GPIO引脚
    (1)
Input: Floating, Pull-up, Pull-down.
    (2)
Output: Push-Pull (Pull-up, Pull-down or no Pull)
.......
楼主,不知道你测试过F407的IO管脚的输出速度吗?我的怎么都不到1MHz啊
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107034
QQ
发表于 2016-1-6 00:58:25 | 显示全部楼层

回 baonng 的帖子

baonng:楼主,不知道你测试过F407的IO管脚的输出速度吗?我的怎么都不到1MHz啊 (2016-01-05 16:45) 
应该是哪里配置或者测试有问题吧,这个是我以前测试的:
http://www.armbbs.cn/forum.php?mod=viewthread&tid=2197
回复

使用道具 举报

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

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-5-15 04:29 , Processed in 0.343139 second(s), 34 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

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