2010-11-06 05:26 PM
how to configure EXTI ?
2011-05-17 05:14 AM
You must enable the AFIO clock, and the GPIOC clock.
The EXTI registers are within the AFIO unit, chances are you haven't enabled it.2011-05-17 05:14 AM
thank you I enabled AFIO clock and it worked
in order not to open a new topic I have another question here I want a timer to tick between 1 Hz and 10 KHz is there an example for this ? ( how to calculate prescaler and reload register for this job ? )2011-05-17 05:14 AM
in order not to open a new topic I have another question here
I want a timer to tick between 1 Hz and 10 KHz
is there an example for this ? ( how to calculate prescaler and reload register for this job ? )
I think I've posted examples before. The basic formula, f = CLK / (p * q), where Prescaler = (p - 1), Period = (q - 1), and where q = less than 65536 I'll post some other examples in a bit.
2011-05-17 05:14 AM
With SYSTICK. provided your main clock is within range.
SysTick_Config(SystemCoreClock / 10); // 10 Hz SysTick_Config(SystemCoreClock / 10000); 10 KHz // TIM4CLK = 36 MHz x = 100; y = 36; // Clock at 1 MHz (36 MHz/36), 100 ticks, 10 KHz or x = 1000; y = 36000; // Clock at 1 KHz (36 MHz/36000), 1000 ticks, 1 Hz RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE); /* Time base configuration */ TIM_TimeBaseStructure.TIM_Period = (x - 1); // 1-65536 TIM_TimeBaseStructure.TIM_Prescaler = (y - 1); // 1-65536 TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; // 1,2 or 4 for tDTS TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);