ResumeAllInterrupts() does not work

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

ResumeAllInterrupts() does not work

ソリューションへジャンプ
1,789件の閲覧回数
wjhtu
Contributor I

Hi, I have a problem when using OsIf_SuspendAllInterrupts() and OsIf_ResumeAllInterrupts() .

I setup a simple project with STM0 in a 5ms periodic interrupt . When I call OsIf_SuspendAllInterrupts() and then call OsIf_ResumeAllInterrupts() immediately  the timer resumes and runs normally. 

But if I do some "heavy work" betweeen these two functions, for example a soft-delay in several minitues, the timer cannot resumes.

My board is S32K344 EVB RED.

Thank you for any help. 

My Code:
 
static int os_timer_ms=0;
void Stm0Ch0Callback(void)
{
os_timer_ms+=5;
if(os_timer_ms>99999)
{
os_timer_ms=0;
}
if(os_timer_ms%1000==0)
printf("os_timer_ms=%d\r\n",os_timer_ms);
}
 
void SoftDelayMs(int ms)
{
for(int i=0;i<ms;i++)
{
for(int j=0;j<16000;j++)
{
int k=i+j;
}
}
}
 
int main(void)
{
BoardInit();
HAL_LED_Init();
HAL_UART_Init();
HAL_STM0_Init();
printf("hello!\r\n");
    for(;;)
    {
    static int timer_ms=0;
    if(timer_ms<os_timer_ms)
    {
    timer_ms=os_timer_ms;
    if(timer_ms==5000)
    {
    printf("a\r\n");
    OsIf_SuspendAllInterrupts();
    printf("b\r\n");
    SoftDelayMs(5000);
    printf("c\r\n");
    OsIf_ResumeAllInterrupts();
    printf("d\r\n");
    }
    }
        if(exit_code != 0)
        {
            break;
        }
    }
    return exit_code;
}

 

0 件の賞賛
返信
1 解決策
1,771件の閲覧回数
Senlent
NXP TechSupport
NXP TechSupport

Hi@wjhtu

When you turn off all interrupts, SMT will still count. Then turn on interrupts after a delay, at this time, the value of CNT is already much greater than the set trigger value, and it will no longer trigger interrupts.
So you can try clearing SMT->CNT after calling OsIf_ResumeAllInterrupts, and everything will be fine.

Senlent_0-1699331397527.png

 

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,772件の閲覧回数
Senlent
NXP TechSupport
NXP TechSupport

Hi@wjhtu

When you turn off all interrupts, SMT will still count. Then turn on interrupts after a delay, at this time, the value of CNT is already much greater than the set trigger value, and it will no longer trigger interrupts.
So you can try clearing SMT->CNT after calling OsIf_ResumeAllInterrupts, and everything will be fine.

Senlent_0-1699331397527.png

 

0 件の賞賛
返信
1,762件の閲覧回数
wjhtu
Contributor I
Yes, it does work! Thank you very much!
0 件の賞賛
返信