//*********************************************************************************************************
#include "systick.h"
void SysTick_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
Systick_Data Systick_AllData = {0};
//SysTick 初始化配置
static uint32_t SysTick_Config(uint32_tticks)
{
SysTick->CTLR = 0x00000000; //控制寄存器复位
SysTick->SR = 0x00000000; //状态寄存器复位
SysTick->CNT = 0x00000000; //计数器复位,设置初始值为0
SysTick->CMP = ticks; //给重加载寄存器赋值
NVIC_SetPriority(SysTicK_IRQn, 3); //设置SysTick中断优先级
NVIC_EnableIRQ(SysTicK_IRQn); //使能开启Systick中断
SysTick->CTLR |= 0x0000000B; //启动系统计数器STK(HCLK/8时基),向上计数到比较值后重新从 0 开始计数
return (0);
}
//SysTick初始化
void Systick_Init(void)
{
//此处在进行初始化的时候设置比较寄存器的值
SysTick_Config(SystemCoreClock / 8000 );//1ms 72M/8000/9000000 = 1/1000 = 1ms
}
//SysTick中断
void SysTick_Handler(void)
{
SysTick->SR = 0;//中断标志位清零
Systick_AllData.Counting_Basis ++;
if(Systick_AllData.Counting_Basis >= 1000)
{
GPIOB->OUTDR ^= ((uint16_t)0x0004);//反转
Systick_AllData.Counting_Basis = 0;
}
}
//*****************************************************************************************************************
#include "debug.h"
#include "gpio.h"
#include "lcd.h"
#include "systick.h"
#include "timer.h"
#include "app_lcd.h"
#include "app_led.h"
int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
SystemCoreClockUpdate();
USART_Printf_Init(115200);
Systick_Init();
TIM1_Int_Init(1000-1,144-1);
Delay_Init();
GPIO_LED_Init();
LCD_Init();
printf("SystemClk:%d\r\n",SystemCoreClock);
printf("This is printf example\r\n");
while(1)
{
Led_light();
// LCD_Disp();
}
}