cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F102CBT6 Timer 4 question

Rob1
Associate II
Posted on November 05, 2013 at 09:51

Hi all.

I'm new to ST micro's so excuse me if this is a dumb question.

I'm working on a project using the above micro. I'm using Atollic as my ide.

I'm trying to get timer 4 working. The code compiles , but in the debugger the  list of

SFR's does not show timer 4. It shows timer 2 and 3 , but not 4. As I understand , the low density devices (STM32F102C4 and C6) don't contain timer 4 , but I'm using the

STM32F102CB , which is supposed to have timer 4 included.

Am I missing something here?

Cheers

Robin
3 REPLIES 3
Posted on November 05, 2013 at 13:57

ST's numbering, suffixes and classes are rather confusing. Beyond the ones I'm specifically using I couldn't tell you what's in a specific one.

You could check the RCC->APBxENR register and check if the TIMx bit is functional to see if it exists, or not. If the peripheral enable is stuck at zero, then it's not present.

A flaw in Atollic's database is something you'll need to discuss with them.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Rob1
Associate II
Posted on November 06, 2013 at 07:37

Hi.

I've managed to get timer4 working(sort of). It's difficult to debug when the SFR is not available in the debugger!!! I've sent a email to Atollic to see if I can get it resolved.

The problem I'm having is the input capture works for capturing rising edge , falling edge , but both edges does not work. Setting to capture both edges also only captures falling edges :0(

Is there something different that has to be done to capture both edges as opposed to only one edge?

Any help appreciated.

cheers

Rob

This is a copy of the relevant code:

  RCC_APB1PeriphClockCmd(RCC_APB1ENR_TIM4EN, ENABLE);

 /* Enable the TIM4 global Interrupt */

      NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQn;

      NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

      NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;

      NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

      NVIC_Init(&NVIC_InitStructure);

  /* TIM4 configuration: Input Capture mode ---------------------

       The external signal is connected to TIM4 CH4 pin (PB.9)

       ------------------------------------------------------------ */

      TIM_ICInitStructure.TIM_Channel = TIM_Channel_4;

      TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_BothEdge;

      TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;

      TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;

      TIM_ICInitStructure.TIM_ICFilter = 0x0;

      TIM_ICInit(TIM4, &TIM_ICInitStructure);

      /* TIM enable counter */

      TIM_Cmd(TIM4, ENABLE);

      /* Enable the CC4 Interrupt Request */

      TIM_ITConfig(TIM4, TIM_IT_CC4, ENABLE);

      GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_9;

      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

      GPIO_Init(GPIOB, &GPIO_InitStructure);

Posted on November 06, 2013 at 20:15

Should be possible to trigger on both edges, it's perceived usability might depend on how close the edges are. The usual method would be a pairing of CH3/CH4 internally so each catch/latch a different edge of the input signal. Or perhaps a PWM input mode?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..