⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer.c

📁 ARM公司ATC培训的所有练习源码
💻 C
字号:
#include "timer.h"
#include "cortexm3.h"
#include "nvic.h"
#define MAGIC_VALUE 299999

#include <stdio.h>


void SysTick_init(void)
{
	int onems = ((NVIC.SysTick.Calibration) & 0x00ffffff);
	int reload = 999; /* Supposed to be once a second (999+1 ms)*/

	/* If the calibration value is non 0 then we can use it as a more accurate value for 1ms */
	if(onems != 0)
	{
		reload = ((onems+1) * 1000)-1;
	}
	/* *SysTickLoad = reload; */
	*SysTickLoad = MAGIC_VALUE; /* Found to be more realistic on ISSM */

#if defined SYSTICK_INTERRUPT
	*SysTickCtrl = SysTickEnable | SysTickInterrupt; /* Start, with interrupts enabled */
#else
	*SysTickCtrl = SysTickEnable; /* Start, with interrupts enabled */
#endif
}

void SysTickHandler(void)
{
	printf("SysTick interrupt.\n\r");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -