2017年12月18日学习总结

今天学习了SYSTICK_Timers 时钟,可以定时,计时,计数,有三大模块分别为:时钟源(决定最小单元)、重载计数、计数

库文件查找,编写程序,封一个延时1S的函数

#include"main.h"

u32 a;

void delay_ms(int n)

{int b=1;

while(b){

if(a>n)

{ a=0;

b=0;

}

}

}

void GPIOH_config(void)

{

GPIO_InitTypeDef GPIO_InitStruct;

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOH, ENABLE);

GPIO_InitStruct.GPIO_Pin  = GPIO_Pin_10;

GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;

GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;

GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;

GPIO_InitStruct.GPIO_PuPd  = GPIO_PuPd_UP;

GPIO_Init(GPIOH, &GPIO_InitStruct);

GPIO_WriteBit(GPIOH, GPIO_Pin_10, Bit_SET);

}

int main(void)

{

GPIOH_config();

SysTick_Config(0x2BF20);

while (1)

{

GPIO_WriteBit(GPIOH, GPIO_Pin_10, Bit_RESET);

delay_ms(1000);

GPIO_WriteBit(GPIOH, GPIO_Pin_10, Bit_SET);

delay_ms(1000);

}

}

你可能感兴趣的:(2017年12月18日学习总结)