Board logo

标题: [NUCLEO-F031K6试用]MDK寄存器版:2、1Hz指示灯 [打印本页]

作者: look_w    时间: 2018-1-24 20:59     标题: [NUCLEO-F031K6试用]MDK寄存器版:2、1Hz指示灯

代码如下:
main.c
#include "stm32f0xx.h"#include "sys.h"#include "systick.h"#include "led.h"int main(void){  SystemCoreClockConfigure();  SystemCoreClockUpdate();  systick_init();  led_init();  while(1)  {// GPIOB->BSRR = 0x1 << 3;// GPIOB->BRR = 0x1 << 3;  }}
systick.c
#include "systick.h"static int tim = 0;int  systick_init(void){  SysTick_Config(SystemCoreClock / 1000);  return 0;}void  SysTick_Handler(void){  static int tt = 0;  if(tim++ - tt > 500)  {  tt = tim;  GPIOB->BSRR = ((GPIOB->ODR & (1 << 3)) > 0) ? (0x1 << 19) : (0x1 << 3);  }}




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0