/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Using interrupts with CircleOS V1.6

Username:     
Password:     
             

Forum

# 1   2007-10-28 13:08:09 Using interrupts with CircleOS V1.6

Squonk
Member
Registered: 2007-10-26
Posts: 10

Using interrupts with CircleOS V1.6

How can I use a hardware interrupt with CircleOS V1.6. Since the vector table is now in RAM this should be possible. Does anybody have a code snipplet for adjusting the interrupt vector?

Regards

   Squonk


"The stupidity of mankind and the universe have no end. But in the case of the universe it is not so sure." A. Einstein

Offline

 

# 2   2007-10-28 14:34:36 Using interrupts with CircleOS V1.6

lionel
Member
From: Grenoble, France
Registered: 2007-07-24
Posts: 71
Website

Re: Using interrupts with CircleOS V1.6

Hello,

the functions to use are :

Code:

void UTIL_SetIrqHandler (int it_number, tHandler it_routine);
tHandler* UTIL_GetIrqHandler (int it_number);

Here is a snippet of Application.c from the PrimerMouse application (it makes use of USB interrupts):

Code:

[...]
tHandler OldHandler;

enum MENU_code Application_Ini ( void )
   {
   [...]
#define ID_IRQ_USB_LP  (0x90)
      
   //Set IRQ Handler
   OldHandler = (tHandler)UTIL_GetIrqHandler( ID_IRQ_USB_LP );
   UTIL_SetIrqHandler(ID_IRQ_USB_LP, (u32)USB_Istr);

   //USB Initialization
   Set_System();  
   USB_Interrupts_Config();
   Set_USBClock();
   USB_Init();
   [...]
   }

regards,
Lionel

Offline

 

# 3   2007-10-28 21:22:42 Using interrupts with CircleOS V1.6

Squonk
Member
Registered: 2007-10-26
Posts: 10

Re: Using interrupts with CircleOS V1.6

Thank You for the very useful information. I guess I should have taken a look into the PrimerMouse Apllication sources earlier!
But another question: Which interupts are used by the CircleOS and which can be used freely by my own application? Is there any hint for this in the documentation, or must I examine the source code of CircleOS?
Best regards
  Squonk


"The stupidity of mankind and the universe have no end. But in the case of the universe it is not so sure." A. Einstein

Offline

 

# 4   2007-10-29 08:04:50 Using interrupts with CircleOS V1.6

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

Re: Using interrupts with CircleOS V1.6

CircleOS uses the systick (scheduler) and the timer2 interupts (to perform the MEMS sampling at a constant rate).

Offline

 

# 5   2008-06-17 00:00:13 Using interrupts with CircleOS V1.6

armaniake
Member
From: USA, Texas
Registered: 2007-08-22
Posts: 38

Re: Using interrupts with CircleOS V1.6

Hi,

What is the rate at which the MEMS is polled at the maximum CPU speed (72Mhz) - Circle_OS1.7?

I understand that TIMER2 calls MEMS_Handler() regularly via interrupt.

It seems that the PCLK1 clock (TIMER 2 CLK) is at 72MHz. I say so because of the x2Multiplier that kicks in when APB1 prescaler is set to a different value than 1. It is the case here as we have:

RCC_Configuration()

   /* PCLK1 = HCLK/2 */
   RCC_PCLK1Config( RCC_HCLK_Div2 );


And from

TIM_Configuration(),

it looks like we setup TIMER 2 for a rate of:

512 * (1/72000000) = 7.1us (140KHz)

Note: MEMS_DIVIDER is set to 1 in MEMS_Handler()

It seems as we were polling the MEMS at 140KHz but that does not make sense as the max ODR = 2560Hz (ODR4, 640Hz).


What am I missing?

Offline

 

# 6   2008-06-17 18:38:44 Using interrupts with CircleOS V1.6

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

Re: Using interrupts with CircleOS V1.6

The pre-division by 256 in the timer.
The max frequency is 140kHz/256 = 546Hz.

Offline

 

# 7   2008-06-17 19:29:08 Using interrupts with CircleOS V1.6

armaniake
Member
From: USA, Texas
Registered: 2007-08-22
Posts: 38

Re: Using interrupts with CircleOS V1.6

I see,

I suppose it is done by   

TIM_Configuration()

...

/* Immediate load of TIM2 Precaler value */
   TIM_PrescalerConfig( TIM2, 0x100, TIM_PSCReloadMode_Immediate );


I missed that point as I am still trying to get a grasp on how to configure the timer for a time base mechanism. Particularly, I'm not sure of what is the difference between:


   TIM_TimeBaseStructure.TIM_Prescaler       = 0x1;

and


   TIM_PrescalerConfig( TIM2, 0x100, TIM_PSCReloadMode_Immediate );


They both seem to hit the TIM2PSC register. Would know a bit more than maybe to tell me what is the distinction between those?


Thank you

Offline

 

# 8   2008-06-18 12:25:20 Using interrupts with CircleOS V1.6

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

Re: Using interrupts with CircleOS V1.6

You are right, the second line seems to overwrite the initial configuration. It will be removed in V1.8 (and replaced by a proper initial (single) configuration).

Offline

 

Board footer