stm32f030例程led
时间: 2023-10-27 12:08:27 浏览: 189
stm32官方例程
5星 · 资源好评率100%
您可以参考以下代码实现stm32f030的LED控制:
```c
#include "stm32f0xx.h"
void delay(uint32_t count) {
for (uint32_t i = 0; i < count; i++);
}
int main(void) {
RCC->AHBENR |= RCC_AHBENR_GPIOCEN; // 使能GPIOC时钟
GPIOC->MODER |= GPIO_MODER_MODER8_0; // PC8设置为输出模式
while (1) {
GPIOC->BSRR = GPIO_BSRR_BS_8; // PC8输出高电平
delay(1000000);
GPIOC->BRR = GPIO_BRR_BR_8; // PC8输出低电平
delay(1000000);
}
}
```
阅读全文