cancel
Showing results for 
Search instead for 
Did you mean: 

Input Capture: Channels and Capture Compare Register

kzawada
Associate II
Posted on July 01, 2010 at 17:38

Input Capture: Channels and Capture Compare Register

3 REPLIES 3
raptorhal2
Lead
Posted on May 17, 2011 at 13:56

Look at Figure 100, All Densities Reference Manual RM008, Rev 10 to see the relationship between channels and capture compare registers.

Cheers, Hal

kzawada
Associate II
Posted on May 17, 2011 at 13:56

I see exactly what you are talking about in Figure 100.  This basically means that there is a 'daisy chain' of configuration that has to be made in order to capture the transitions on TIM4_CH4.  It is the following:

(1) TIM4_CH3

(2) TI3

(3) Input Filter/Edge Detector

(4) IC3

(5) Prescalar

(6) IC3PS

(7) Capture/Compare 4 Register

The configuration for making IC3 = TI3 is set by ''TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;''.

For some reason when I configure TIM4_CH3 (TI3) to be selected as IC3 I cannot get my firmware to generate an interrupt and call ''TIM4_IRQHandler()''.  I am using Keil RL-RTX and the library provided by Keil in ''C:\Keil\ARM\RV31\LIB\ST\STM32F10x'', where the NVIC is configured for TIM4_IRQChannel (=0x1F in Keil Library).

Is there anyway to troubleshoot why timer 4 is not generating an interrupt that calls the TIM4_IRQHandler() function?

The code modification that I have made is the following:

void InitializeInputCapture(void)

{

    TIM_ICInitTypeDef  TIM_ICInitStructure;

    GPIO_InitTypeDef GPIO_InitStructure;

    NVIC_InitTypeDef NVIC_InitStructure;

    // RCC Configuration -------------------------------------------------------

    // TIM3 clock enable

    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);

   

    // GPIOA and GPIOB clock enable

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);

    // Configure the Nested Interrupt Vector -----------------------------------

    // Enable the TIM3 global Interrupt

    NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQChannel;

    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;

    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

    NVIC_Init(&NVIC_InitStructure);

    // Input Capture Pin Configuration -----------------------------------------

    GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_8;

    //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_Init(GPIOB, &GPIO_InitStructure);

    // Input Capture Configuration ---------------------------------------------

    TIM_ICInitStructure.TIM_Channel = TIM_Channel_3;

    TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;

    TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;

    TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV8;

    TIM_ICInitStructure.TIM_ICFilter = 0x0;

   

    TIM_ICInit(TIM4, &TIM_ICInitStructure);

   

    // TIM enable counter

    TIM_Cmd(TIM4, ENABLE);

   

    // Enable the CC2 Interrupt Request

    TIM_ITConfig(TIM4, TIM_IT_CC3, ENABLE);

}

kzawada
Associate II
Posted on May 17, 2011 at 13:56

The corresponding configuration is the following:

0690X00000604y4QAA.png