The advanced control timers have different uses:
1, the basic timing.
2. Measure the pulse width of the input signal (input capture)
3. Produce output waveform (output comparison, PWM and single pulse mode)
4, corresponding to different events (capture, comparison, overflow, braking, triggering) of the interruption.
The clock source of the advanced control timer can be either an internal clock or an external signal, which can be selected through the configuration register.
Up to 4 independent channels can be configured
1. Input capture
2. Output comparison
3. PWM generation
4, single pulse mode output
static void Tim1_init (void)
{
/* Set the Prescaler value */
TIM1->PSCRH = (U8) (prescaler_tim1 >> 8);//f_time1 = f_sys/(prescaler_tim1 + 1)
TIM1->PSCRL = (U8) (PRESCALER_TIM1);
/* Set the Autoreload value */
Tim1->arrh = (U8) (0xFFFF >> 8);
TIM1->ARRL = (U8) (0XFFFF);
/* Select the Counter Mode */
TIM1->CR1 = (U8) (((TIM1->CR1) & (U8) (~ (Tim1_cr1_cms | tim1_cr1_dir))) | TIM1_COUNTERMODE_UP);//Control register
/* Set the repetition Counter value */
TIM1->RCR = 0;
}
TIM1_CNTRH: Counter 8 bits High
Tim1_cntrl: Counter 8 bits Low
TIM1_PSCRH: Prescaler 8 bits high
TIM1_PSCRL: Prescaler Low 8-bit
TIM1_ARRH: Auto Reload Register high 8 bit
TIM1_ARRL: Auto Reload register low 8 bit
When the value of the automatic reload is empty, the counter does not work.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.