FreeRTOS时钟配置——Cortex-M3

在Cortex-M3的移植中

FreeRTOS会用以下两个变量来配置SysTick定时器,所以不用再自己配置SysTick

#define configCPU_CLOCK_HZ ( ( unsigned long ) 72000000 )

#define configTICK_RATE_HZ ( ( portTickType ) 1000 )

 

port.c文件有

 

/*
 * Setup the SysTick timer to generate the tick interrupts at the required
 * frequency.
 */
#if configOVERRIDE_DEFAULT_TICK_CONFIGURATION == 0

	void vPortSetupTimerInterrupt( void )
	{
		/* Calculate the constants required to configure the tick interrupt. */
		#if configUSE_TICKLESS_IDLE == 1
		{
			ulTimerCountsForOneTick = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ );
			xMaximumPossibleSuppressedTicks = portMAX_24_BIT_NUMBER / ulTimerCountsForOneTick;
			ulStoppedTimerCompensation = portMISSED_COUNTS_FACTOR / ( configCPU_CLOCK_HZ / configSYSTICK_CLOCK_HZ );
		}
		#endif /* configUSE_TICKLESS_IDLE */

		/* Configure SysTick to interrupt at the requested rate. */
		portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;;
		portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT;
	}

#endif /* configOVERRIDE_DEFAULT_TICK_CONFIGURATION */


 

 

 

第19,20行即为配置SysTick的语句,故不用再自己配置SysTick定时器

 

你可能感兴趣的:(FreeRTOS学习笔记)