Note:As several pins provide a connection to multiple GPIOs, the mode selection for any of those GPIOs impacts all the other GPIOs connected to the same pin. The user is responsible for the proper setting of the GPIO modes in order to avoid conflicts between GPIOs bonded to the same pin (including their alternate functions). For example, pull-up enabled on PD1 is also seen on PC6, PD3 and PD5. Push-pull configuration of PC3 is also seen on PC4 and PC5, etc.数据手册上这段话的意思是不是说,几个I/O连在同一个管脚上时,设置一个I/O会影响到其它的I/O变成同样的功能
举例说,如果这个管脚定义有PA9/USART_TX,那么如果你想作为普通的IO口用,那就初始化PA9的输入输出方向、管脚速度等即可;如果想作为USART_TX用,那就再对USART1进行初始化,开启USART1的时钟和使能。
如果是想重映射,那就需要开启AFIO时钟。
按照楼主的意思,应该只是想用复用功能,所以想作为普通IO,就配置IO就行(就点LED灯的那种配置就行);如果是想用外设(USART1,I2C,SPI),那就再加上相应外设的初始化,开启时钟和使能。
评分
查看全部评分
比如你用PA1。定义了输出,那么你直接操作PA1的相关寄存器就行。
再比如你要用AD,开了ad通道,那么内部的集成外设就接管了这个脚。需要注意的是他同时还是那个PDx。想按IO访问也是可以的。并且根据规范,AD口对应引脚必须设置为无上拉输入模式。
以此类推。设计需要的就是把需要的功能脚拉对了,硬件通了,软件就开对应功能做需要的事就好了。
先看数据手册和用户指导手册,然后各外设的跑样例程序。
评分
查看全部评分
评分
查看全部评分
评分
查看全部评分
f:\无标题
点评
评分
查看全部评分
评分
查看全部评分