freeRTOS and delays

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

freeRTOS and delays

2,387件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by OXO on Wed Jul 11 05:37:30 MST 2012
Hi all,

I need an accurate delay in an app to be used before the freertos systick is enabled. Has anyone come up with a nice way to do this?

Chris
0 件の賞賛
返信
5 返答(返信)

2,263件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by  on Thu Jul 12 01:12:15 MST 2012

Quote:
for(unsigned long ul = 0; ul < 0xfffff; ul++ )
{

}



The OP requested an accurate delay, and that is never going to be accurate.

The only way of a truly accurate delay is to use a hardware timer, as per somebody else's suggestion.  You can use the SysTick for this before the FreeRTOS scheduler is started, but not after.  The RTOS will re-configure the SysTick when it starts.  However, you cannot use the SysTick interrupt as the RTOS interrupt handler needs to be installed.
0 件の賞賛
返信

2,263件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by FlySnake on Wed Jul 11 10:14:22 MST 2012
Use hardware timer
#include "lpc17xx_timer.h"
void Timer0_Wait(uint32_t ms)
{
TIM_TIMERCFG_Type TIM_ConfigStruct;
TIM_MATCHCFG_Type TIM_MatchConfigStruct ;

        // Initialize timer 0, prescale count time of 1ms
TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_USVAL;
TIM_ConfigStruct.PrescaleValue= 1000;
// use channel 0, MR0
TIM_MatchConfigStruct.MatchChannel = 0;
// Enable interrupt when MR0 matches the value in TC register
TIM_MatchConfigStruct.IntOnMatch   = TRUE;
//Enable reset on MR0: TIMER will not reset if MR0 matches it
TIM_MatchConfigStruct.ResetOnMatch = FALSE;
//Stop on MR0 if MR0 matches it
TIM_MatchConfigStruct.StopOnMatch  = TRUE;
//do no thing for external output
TIM_MatchConfigStruct.ExtMatchOutputType =TIM_EXTMATCH_NOTHING;
// Set Match value, count value is ms (timer * 1000uS =timer mS )
TIM_MatchConfigStruct.MatchValue   = ms;

// Set configuration for Tim_config and Tim_MatchConfig
TIM_Init(LPC_TIM0, TIM_TIMER_MODE,&TIM_ConfigStruct);
TIM_ConfigMatch(LPC_TIM0,&TIM_MatchConfigStruct);
// To start timer 0
TIM_Cmd(LPC_TIM0,ENABLE);
while ( !(TIM_GetIntStatus(LPC_TIM0,0)));
TIM_ClearIntPending(LPC_TIM0,0);
}
0 件の賞賛
返信

2,263件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tom84 on Wed Jul 11 06:21:08 MST 2012
ok, i see.
you could write your on crude delay function, like

  for(unsigned long  ul = 0; ul < 0xfffff; ul++ )
            {

            }
0 件の賞賛
返信

2,263件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by OXO on Wed Jul 11 06:11:10 MST 2012

Quote: tom84
[SIZE=2]Hi,[/SIZE]

[SIZE=2]search for vTaskDelay(). It is a delay from the freeRTOS souce.[/SIZE]





The freertos timers do not run before the freertos tick is enabled. so vTaskDelay will wait forever

. but thanks for the reply ;)
0 件の賞賛
返信

2,263件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tom84 on Wed Jul 11 05:44:27 MST 2012
[SIZE=2]Hi,

search for vTaskDelay(). It is a delay from the freeRTOS souce.
[/SIZE][SIZE=2][/SIZE]
[SIZE=2][/SIZE]
[SIZE=2][/SIZE]
0 件の賞賛
返信