How can I register a function for an interrupt in STM?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
JGPark
Level 1
Level 1
25 sign-ins 5 questions asked 10 sign-ins

Hi, I am looking into STM_Interrupt_1_KIT_TC277_TFT, STM_Interrupt.c example.

What I am curious about is, how is the function registered for interrupt?

 

In C file, LED toggle happens every 500ms by interrupts.

All I could find was below snippet relating to interrupt registration.

It means below isrSTM function is called every 500ms by interrupt.

 

 

 

IFX_INTERRUPT(isrSTM, 0, ISR_PRIORITY_STM);

void isrSTM(void)
{
    /* Update the compare register value that will trigger the next interrupt and toggle the LED */
    IfxStm_increaseCompare(STM, g_STMConf.comparator, g_ticksFor500ms);
    IfxPort_setPinState(LED, IfxPort_State_toggled);
}

 

 

 

 

I only found related snippet regarding registration of an interrupts.

 

 

 

IFX_INTERRUPT(isrSTM, 0, ISR_PRIORITY_STM);

void isrSTM(void)
{
    /* Update the compare register value that will trigger the next interrupt and toggle the LED */
    IfxStm_increaseCompare(STM, g_STMConf.comparator, g_ticksFor500ms);
    IfxPort_setPinState(LED, IfxPort_State_toggled);
}

/* Function to initialize the STM */
void initSTM(void)
{
    IfxStm_initCompareConfig(&g_STMConf);           /* Initialize the configuration structure with default values   */

    g_STMConf.triggerPriority = ISR_PRIORITY_STM;   /* Set the priority of the interrupt                            */
    g_STMConf.typeOfService = IfxSrc_Tos_cpu0;      /* Set the service provider for the interrupts                  */
    g_STMConf.ticks = g_ticksFor500ms;              /* Set the number of ticks after which the timer triggers an
                                                     * interrupt for the first time                                 */
    IfxStm_initCompare(STM, &g_STMConf);            /* Initialize the STM with the user configuration               */
}

 

 

 


Basically, is it really all for registration of an interrupt?

How can their relationship be set between STM interrupt which is triggered via CMP match, and isrSTM?

Is it tied with the information relating to ISR_PRIORITY_STM (priority of interrupt)? It seems like priority also is used as such as ID for interrupts because I found it out in the UM

The SRPN is used by service providers to select an Interrupt Service Routine (ISR))
or DMA channel to service the request

 

I would like to know where I have to look around more.

It will be appreciated if you give me a hint. Thanks.

 

0 Likes
1 Solution
Meet_T
Moderator
Moderator
Moderator
100 solutions authored 25 likes received 50 solutions authored

Hi @JGPark ,

 

IfxStm_initCompare(STM, &g_STMConf); instruction initializes the interrupt by writing the configured TOS and Priority in the SRC registers.

 

 IFX_INTERRUPT(isrSTM, 0, ISR_PRIORITY_STM); the macro is mapping the function isrSTM in the interrupt vector table based on the priority of the interrupt configured( ISR_PRIORITY_STM), please make sure that Priority value written in the SRC register and in this Macro are same as the mapping to the vector table will be done according to this priority.

 

Best Regards,

Meet.

View solution in original post

0 Likes
1 Reply
Meet_T
Moderator
Moderator
Moderator
100 solutions authored 25 likes received 50 solutions authored

Hi @JGPark ,

 

IfxStm_initCompare(STM, &g_STMConf); instruction initializes the interrupt by writing the configured TOS and Priority in the SRC registers.

 

 IFX_INTERRUPT(isrSTM, 0, ISR_PRIORITY_STM); the macro is mapping the function isrSTM in the interrupt vector table based on the priority of the interrupt configured( ISR_PRIORITY_STM), please make sure that Priority value written in the SRC register and in this Macro are same as the mapping to the vector table will be done according to this priority.

 

Best Regards,

Meet.

0 Likes