打印
[STM8]

实验分享-【 STM8-SO8-DISCO 评测贴 2 -- GPIO】

[复制链接]
263|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
①开发环境搭建根据官方的release note 描述,IAR STM8 3.10.1 环境下添加了STM8S001J3 系列的支持,所以开发环境如果要使用 IAR 的话版本至少为 3.10.1 低于该版本未进行安装确认,只是根据官方描述来说明。


IAR 工程模板的创建可以参考如下链接,对 IAR 使用熟悉的绕过。

IAR for STM8系列教程(一)

②下载标准库,并修改代码

可以从官网下载的便准库,如下是从官网下载的库文件:
en.stsw-stm8S069.rar (10.66 MB, 下载次数: 1) 查看 stm8 标准库接口和 stm32 有种熟悉的感觉熟悉的味道,感觉似曾相识。



根据接口的注释可以发现,本实验闪烁一颗LED,只需要使用如下连个接口函数即可。

使用 GPIO_Init 接口配置 GPIO 为输出模式。

  • void GPIO_Init  ( GPIO_TypeDef *  GPIOx,
  •   GPIO_Pin_TypeDef  GPIO_Pin,
  •   GPIO_Mode_TypeDef  GPIO_Mode
  • )
  • Initializes the GPIOx according to the specified parameters.
  • Parameters:
  • GPIOx : Select the GPIO peripheral number (x = A to I).
  • GPIO_Pin : This parameter contains the pin number, it can be any value of the GPIO_Pin_TypeDef enumeration.
  • GPIO_Mode : This parameter can be a value of the GPIO_Mode_TypeDef enumeration.


[color=rgb(51, 102, 153) !important]复制代码

使用 GPIO_WriteReverse 翻转 GPIO 电平,外加延时处理即可实现LED 的闪烁效果。
  • void GPIO_WriteReverse  ( GPIO_TypeDef *  GPIOx,
  •   GPIO_Pin_TypeDef  PortPins
  • )
  • Writes reverse level to the specified GPIO pins.
  • Note:
  • The port must be configured in output mode.
  • Parameters:
  • GPIOx : Select the GPIO peripheral number (x = A to I).
  • PortPins : Specifies the pins to be reversed to the port output. data register.


[color=rgb(51, 102, 153) !important]复制代码

根据电路图可知,板上的LED1连接至 GPIOA3 引脚,控制该引脚即可点亮熄灭LED1.



③调试运行
下载程序运行效果如下:


本文转载于【 STM8-SO8-DISCO 评测贴 2 -- GPIO】
http://www.stmcu.org.cn/module/forum/thread-619214-1-1.html



使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:每天都要开心呀

210

主题

505

帖子

4

粉丝