/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / UTIL_SetTimer problem on Primer2 with CircleOS 4.5

Username:     
Password:     
             

Forum
  • Index
  •  » circleOS
  •  » UTIL_SetTimer problem on Primer2 with CircleOS 4.5

# 1   2013-09-12 12:06:32 UTIL_SetTimer problem on Primer2 with CircleOS 4.5

ehiker
New member
From: Prague
Registered: 2009-11-07
Posts: 3

UTIL_SetTimer problem on Primer2 with CircleOS 4.5

Dear colleagues,
I have problem with the function UTIL_SetTimer on Primer2 with installed CircleOS 4.5. I used this function according to the instruction described in the document "CircleOS V4.5 Conception document", but my timer handler was never called. I looked for the reason, why my timer handler was not called. I looked in the debugger, that timer TIM2 was running. I found differences in source code of CircleOS for the platform Primer2 and Open4, please see bellow. I did not found interrupt handler, that decreases variable CurrentTimerDelay on Primer2. I  can not found any note, that the function UTIL_SetTimer is not supported on Primer2 platform.

Some parts of the CircleOS 4.5 source files are pasted bellow.

Circle-OS-4.5\Circle\OS\Hardware\STM32\src\util_spe.c

Code:

/****************** COPYRIGHT (C) 2007-2013 KEOLABS S.A.S. ********************/
/**
*
* @file     Util_spe.c
* @brief    Various harware specific utilities for CircleOS.
* @author   YRT
* @date     05/2011
* @note     Platform Open4 STM32
*
* @version  4.4 Add UTIL_SetTimer
* @date     11/2012
*
**/
/******************************************************************************/

/* Private defines -----------------------------------------------------------*/
#define TIMER_MULT_RATIO 110 
#define TIMER_DIV_RATIO 200

/* Private variables ---------------------------------------------------------*/
u32                  CurrentTimerDelay = 0; 
void                 (*CurrentEventTimer)  ( void ) = 0;

/*******************************************************************************
*
*                                UTIL_SetTimer
*
*******************************************************************************/
/**
*
*  Program a timer event. 
*
*  @param[in]  millisec         duration to wait before calling the event handler
*  @param[in]  fTimerHandler    function to be call when the delay will elapse
*  @return  void
*
**/
/********************************************************************************/
void UTIL_SetTimer ( u32 millisec,  void  (*fTimerHandler)  ( void )  )
    {
    CurrentTimerDelay = ( millisec * TIMER_MULT_RATIO ) / TIMER_DIV_RATIO ;
    if (!CurrentTimerDelay) CurrentTimerDelay = 1;
    CurrentTimerDelay = ( CurrentTimerDelay * freqTIM2[CurrentSpeed]) / freqTIM2[SPEED_MEDIUM];
    CurrentEventTimer = fTimerHandler ;
    return;
    }

Circle-OS-4.5\Circle\OS\Hardware\Primer_1_2\src\stm32f10x_circle_it_spe.c

Code:

/****************** COPYRIGHT (C) 2007-2013 KEOLABS S.A.S. ********************/
/**
*
* @file     stm32f10x_circle_it_spe.c
* @brief    Interrupt handler for the CircleOS project.
* @author   FL
* @author   IB
* @date     07/2007
* @version  4.0
* @date     05/2010 Folder reorganization
*
* @note     Platform = Primer1 & 2
*
**/
/******************************************************************************/

/*******************************************************************************
*
*                                TIM2_IRQHandler
*
*******************************************************************************/
/**
*
*  Handles the TIM2 global interrupt request.
*
**/
/******************************************************************************/
IRQ void TIM2_IRQHandler( void )
{
#ifdef TIMING_ANALYSIS     // to debug with a scope
    GPIO_WriteBit( GPIOA, GPIO_Pin_7, Bit_RESET );
#endif

    /* Clear TIM2 update interrupt */
    TIM_ClearITPendingBit( TIM2, TIM_IT_Update );

    MEMS_Handler();

#ifdef TIMING_ANALYSIS     // to debug with a scope
    GPIO_WriteBit( GPIOA, GPIO_Pin_7, Bit_SET );
#endif
}

Circle-OS-4.5\Circle\OS\Hardware\OPEN4\STM32\src\stm32f10x_circle_it_spe.c

Code:

/****************** COPYRIGHT (C) 2007-2013 KEOLABS S.A.S. ********************/
/**
*
* @file     stm32f10x_circle_it_spe.c
* @brief    Interrupt handler for the CircleOS project.
* @author   FL
* @author   IB
* @date     07/2007
* @version  4.0
* @date     08/2010
* @note     Platform = Open4 STM32C & STM32E
**/
/******************************************************************************/

/*******************************************************************************
*
*                                TIM2_IRQHandler
*
*******************************************************************************/
/**
*
*  Handles the TIM2 global interrupt request.
*
**/
/******************************************************************************/
IRQ void TIM2_IRQHandler( void )
{
#ifdef TIMING_ANALYSIS     // to debug with a scope
    GPIO_WriteBit( GPIOA, GPIO_Pin_0, Bit_RESET );
#endif

    /* Clear TIM2 update interrupt */
    TIM_ClearITPendingBit( TIM2, TIM_IT_Update );

    if (pMEMS_Handler)
        {
        pMEMS_Handler();
        }

    if ( CurrentTimerDelay ) 
        {
        if ( !--CurrentTimerDelay && CurrentEventTimer )
            {
            void (*CurrentEventTimerTmp)(void) = CurrentEventTimer;

            CurrentEventTimer = 0;  //Clear the event (that could be reloaded by a periodic event).
            CurrentEventTimerTmp(); //And call it.
            }
        }

#ifdef TIMING_ANALYSIS     // to debug with a scope
    GPIO_WriteBit( GPIOA, GPIO_Pin_0, Bit_SET );
#endif
}

Offline

 

# 2   2013-09-14 18:50:10 UTIL_SetTimer problem on Primer2 with CircleOS 4.5

ehiker
New member
From: Prague
Registered: 2009-11-07
Posts: 3

Re: UTIL_SetTimer problem on Primer2 with CircleOS 4.5

I tried to change Tim2 interrupt handler in CircleOS 4.5 for Primer2 and then function UTIL_SetTimer worked correctly.

Circle-OS-4.5\Circle\OS\Hardware\Primer_1_2\src\stm32f10x_circle_it_spe.c

Code:

IRQ void TIM2_IRQHandler( void )
{
#ifdef TIMING_ANALYSIS     // to debug with a scope
    GPIO_WriteBit( GPIOA, GPIO_Pin_7, Bit_RESET );
#endif

    /* Clear TIM2 update interrupt */
    TIM_ClearITPendingBit( TIM2, TIM_IT_Update );

    MEMS_Handler();

#ifdef TIMING_ANALYSIS     // to debug with a scope
    GPIO_WriteBit( GPIOA, GPIO_Pin_7, Bit_SET );
#endif
}

Code:

IRQ void TIM2_IRQHandler( void )
{
#ifdef TIMING_ANALYSIS     // to debug with a scope
    GPIO_WriteBit( GPIOA, GPIO_Pin_7, Bit_RESET );
#endif

    /* Clear TIM2 update interrupt */
    TIM_ClearITPendingBit( TIM2, TIM_IT_Update );

    MEMS_Handler();

    if ( CurrentTimerDelay ) 
        {
        if ( !--CurrentTimerDelay && CurrentEventTimer )
            {
            void (*CurrentEventTimerTmp)(void) = CurrentEventTimer;

            CurrentEventTimer = 0;  //Clear the event (that could be reloaded by a periodic event).
            CurrentEventTimerTmp(); //And call it.
            }
        }

#ifdef TIMING_ANALYSIS     // to debug with a scope
    GPIO_WriteBit( GPIOA, GPIO_Pin_7, Bit_SET );
#endif
}

Last edited by ehiker (2013-09-14 18:51:34)

Offline

 

# 3   2013-09-16 15:35:43 UTIL_SetTimer problem on Primer2 with CircleOS 4.5

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: UTIL_SetTimer problem on Primer2 with CircleOS 4.5

Hi Ehiker,

You're right, we have forgotten some code to implement this new functionality into Primer2 sources (UTIL_SetTimer was initially developed for STM32E Open4 platform).
Thanks for your report,
Yrt

Offline

 

  • Index
  •  » circleOS
  •  » UTIL_SetTimer problem on Primer2 with CircleOS 4.5

Board footer