STM32F103R6的Keil和Protues仿真-点亮LED灯

STM32F103R6的Keil和Protues仿真-点亮LED灯

  • STM32F103R6的Keil和Protues仿真-点亮LED灯
    • 1、效果
      • 1.1、低电平点亮
      • 1.2、高电平点亮
    • 2、代码
      • 2.1、Keil
      • 2.2、protues
      • https://gitee.com/xiaolixi/l-stm32/tree/master/STM32Protues/diandeng-low
      • https://gitee.com/xiaolixi/l-stm32/tree/master/STM32Protues/diandeng-high

STM32F103R6的Keil和Protues仿真-点亮LED灯

1、效果

1.1、低电平点亮

STM32F103R6的Keil和Protues仿真-点亮LED灯_第1张图片

STM32F103R6的Keil和Protues仿真-点亮LED灯_第2张图片

STM32F103R6的Keil和Protues仿真-点亮LED灯_第3张图片

1.2、高电平点亮

  • 注意高电平点亮只是仿真,真实还是使用低电平点亮。需要设置LED点亮的电流,否则LED不会亮。
    STM32F103R6的Keil和Protues仿真-点亮LED灯_第4张图片

2、代码

2.1、Keil

  • 高电平点亮
    • https://gitee.com/xiaolixi/l-stm32/tree/master/STM32ProjectKeil/2-1tem-ld-high
#include "stm32f10x.h"                  // Device header

int main(void)
{
	RCC->APB2ENR = 0x00000010; # 开启时钟
	
	GPIOC->CRH = 0x00300000; # 推挽输出
	GPIOC->ODR = 0x00002000; # 高电平
	while(1) {
		
	}
}
  • 低电平点亮
    • https://gitee.com/xiaolixi/l-stm32/tree/master/STM32ProjectKeil/2-1tem-ld-low
#include "stm32f10x.h"                  // Device header

int main(void)
{
	RCC->APB2ENR = 0x00000010;
	
	GPIOC->CRH = 0x00300000;
	GPIOC->ODR = 0x00000000; # 输出低电平
	while(1) {
		
	}
}

2.2、protues

https://gitee.com/xiaolixi/l-stm32/tree/master/STM32Protues/diandeng-low

https://gitee.com/xiaolixi/l-stm32/tree/master/STM32Protues/diandeng-high

你可能感兴趣的:(stm32,嵌入式硬件,单片机)