Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement