/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / What is the frequency the Application_Handler( ) function being called

Username:     
Password:     
             

Forum
  • Index
  •  » circleOS
  •  » What is the frequency the Application_Handler( ) function being called

# 1   2008-01-05 02:52:20 What is the frequency the Application_Handler( ) function being called

jingxizhang
Member
Registered: 2007-12-13
Posts: 35

What is the frequency the Application_Handler( ) function being called

According to the STM32-Primer-Manual, once an application is run (usually through a menu selection), CircleOS will first call an initialization routine for the application, then will repeatedly call the application handler at the Systick frequency until it returns a MENU_LEAVE value. When CPU is running at 36 MHz, the Systick frequency is about 1.5 KHz (36MHz / 24000). The Application_Handler( ) function should be called repeatedly at 1500 times per second. However, I found the Application_Handler( ) calling frequency is much slower than the documented rate. I wrote a simple application handler function as following:

enum MENU_code Application_Handler ( void )
{
   static int count = 0;
   if((count % 10) == 0 )
   {
      char msg[16];
      UTIL_uint2str(msg, count, 8, 0);
      DRAW_DisplayString(5, 20, msg, sizeof(msg));
   }
   ++count;
}

The count is reported at 10 times slower than the Systick frequency. Can someone tell me what frequency is the application handler function being called?

Thank you,

Jingxi

Offline

 

# 2   2008-01-17 15:49:34 What is the frequency the Application_Handler( ) function being called

Stewee
Member
From: Dorset/England
Registered: 2007-10-11
Posts: 47
Website

Re: What is the frequency the Application_Handler( ) function being called

The STM32-Primer  manual of July 2007 vintage is wrong for circleOS 1.7.
The Application_Handler() is called every 100 sys ticks; (See Details below)

speed sysclk    /24000=systick   /100=Application handler
-----   ------     -------------       ----------------   
1        18 MHz   750 Hz              7.5Hz   133 ms
2        24 MHz   1000 Hz             10 Hz   100 ms
3        36 MHz   1500 Hz             15 Hz    66 ms
4        48 MHz   2000 Hz             20 Hz    50 ms
5        72 MHz   3000 Hz             30 Hz    33 ms

The 24000 comes from the fact we use 3000 counts of HCLK/8. See sheduler.c:SysTick_Configuration();




Details;- (CircleOS 1.7)
====

  SysTickHandler is listed in CircleStartup.c:g_pfnVectors[] table.

  So when SysTick interrupt occurs scheduler.c:SystickHandler() is called.

  Each scheduler.c:SysTickHandler() interrupt calls every function pointed to
  in scheduler.c:SchHandler[]
     (null function pointers are skipped and pointer value of -1 indicates end of list)

  One of these function pointers listed in scheduler.c:SchHandler[] is
  menu.c:Menu_Handler() which calls YOUR Application_Handler()
  pointed to by CurrentCommand->Fct_Manage
  every MENU_DIVIDER (100) sys ticks ;-
 
    if( ++divider % MENU_DIVIDER )   // Continue only every MENU_DIVIDER(=100) calls.
       return;                       // (note; trivial bug when divider reaches 0xffffffff)
   
    if( CurrentCommand && CurrentCommand->Fct_Manage )  // check Application is still active (not null)
    {
      ret = CurrentCommand->Fct_Manage();              // this calls App_Handler()

      if( ret == MENU_LEAVE )
      {
         MENU_Remove ();
         CurrentMenu = 0;
      }
      return;
    }

====

Last edited by Stewee (2008-01-17 17:01:25)


( Please Give Blood http://www.blood.co.uk >50% can.  5% do. )

Offline

 

# 3   2008-01-17 16:29:33 What is the frequency the Application_Handler( ) function being called

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: What is the frequency the Application_Handler( ) function being called

Note that if you need to call more often your application handler (or any function), you could do it  by adding it in the table of the handlers (see functions UTIL_SetSchHandler and UTIL_GetSchHandler).
In such a case, you must restore the orignal table when exiting your application.

Offline

 

# 4   2008-01-17 19:40:06 What is the frequency the Application_Handler( ) function being called

Stewee
Member
From: Dorset/England
Registered: 2007-10-11
Posts: 47
Website

Re: What is the frequency the Application_Handler( ) function being called

So I cannot have a function run in the background after an application1 closes to capture the display of an application2?  Is that because  the application2 would be re-allocated the same RAM?


( Please Give Blood http://www.blood.co.uk >50% can.  5% do. )

Offline

 

# 5   2008-01-17 20:30:13 What is the frequency the Application_Handler( ) function being called

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: What is the frequency the Application_Handler( ) function being called

You are correct.
We could improve CircleOS in the future by adding a simple memory allocator for  the "shared memory". In such a case, a function could be left  "running in the background" if it addresses only the automatic variables (stack), and the allocated data (no global variables). But we would have still the issue with the pointer to the allocated data (that cannot be neother stacked, nor provided by the memory allocatior. Probably that we will have to "save" one DWORD for each application (the pointer to the allocated data).

However, if a function does not need any global variable, it  could be already left . On the other hand, the main interest of such a function would be to handle some hardware peripherals. But you need to be sure that the other applications do not use the same hardware peripherals.

Offline

 

  • Index
  •  » circleOS
  •  » What is the frequency the Application_Handler( ) function being called

Board footer