|
在AN1018中写到:
The ARM Cortex-M3 has a built-in timer which was designed specifically for RTOS use. The timer can be configured to run at just about any tick rate. The application’s BSP should set this timer to OS_TICKS_PER_SEC.
我想问下这个过程是如何实现的,即用定时器如何实现OS_TICKS_PER_SEC为所设定的值,在AN1913中写到:
BSP_Init() is called by the application code to initialize critical processor features (particularly the μC/OS-II tick interrupt) after multitasking has started (i.e., OS_Start() has been called). This function should be called before any other BSP functions are used. See Listing 5-1 for more details.
即在BSP_Init中完成了定时器的初始化,来实现μC/OS-II tick interrupt,再看BSP_Init()函数,如下:
void BSP_Init (void) {
BSP_RCC_Init();
BSP_ADC_Init();
BSP_LED_Init();
BSP_PB_Init();
BSP_Joy_Init();
}
我想应该是在BSP_RCC_Init();中初始化定时器的,BSP_RCC_Init()代码如下:
static void BSP_RCC_Init (void)
{
CPU_INT32U rcc_to; /* RCC registers timeout */
RCC_DeInit(); /* Reset the RCC clock config to the default reset state */
RCC_HSEConfig(RCC_HSE_ON); /* HSE Oscillator ON */
rcc_to = BSP_RCC_TO_VAL;
while ((rcc_to > 0) &&
(RCC_WaitForHSEStartUp() != SUCCESS)) { /* Wait until the oscilator is stable */
rcc_to--;
}
FLASH_SetLatency(FLASH_Latency_2);
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9); /* Fcpu = (PLL_src * PLL_MUL) = (8 Mhz / 1) * (9) = 72Mhz */
RCC_PLLCmd(ENABLE);
rcc_to = BSP_RCC_TO_VAL;
while ((rcc_to > 0) &&
(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)) {
rcc_to--;
}
RCC_HCLKConfig(RCC_SYSCLK_Div1); /* Set system clock dividers */
RCC_PCLK2Config(RCC_HCLK_Div1);
RCC_PCLK1Config(RCC_HCLK_Div2);
RCC_ADCCLKConfig(RCC_PCLK2_Div6);
FLASH_SetLatency(FLASH_Latency_2); /* Embedded Flash Configuration */
FLASH_HalfCycleAccessCmd(FLASH_HalfCycleAccess_Disable);
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
}
不知道是怎么用那个built-in timer来实现μC/OS-II tick interrupt的,请大虾指教,谢谢。 |
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|