cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4

ChHs_4614611
New Contributor II

HI ,

     I use 1ms system tick sample code . System LED toggle per 100ms.

     It is OK no problem.

     When I add other function. like SPI and Capsence...etc.

    LED toggle time is will exceed 100ms.

     How to setting 1ms timer priority to high priority ?

     My code is under below.

    pastedImage_1.png

pastedImage_0.png

pastedImage_2.png

0 Likes
1 Solution
LinglingG_46
Moderator
Moderator

If it is the priority issue, please try to use the below API to change the NVIC priority:


    NVIC_SetPriority (CY_INT_SYSTICK_IRQN, (1UL << __NVIC_PRIO_BITS) - 2UL); // You can change the 2UL to (0,1,2,3,4)

    CySysTickStart();
   
    t= NVIC_GetPriority(CY_INT_SYSTICK_IRQN); // Get the t to judge whether it is successful to change the priority
   
     UART_PutHexByte(t); // use the debug interface to check the value

Hope it can be helpful for you!

View solution in original post

7 Replies
MotooTanaka
Esteemed Contributor

Hi,

I wonder if it's the interrupt priority or following block is pre-empted by other interrupts

====================

     if (AS_TRUE == Sys1msTask) {

          ..

     }

====================

So if only toggle the LED each 100ms how about do it inside the isr?

Something like

===================

volatile uint32_t led_tick_count = 0 ;

CY_ISR(SysTick_ISR)

{

    led_tick_count++ ;

    if ((led_tick_count % 100) == 0) {

        led_tick_count = 0 ;

        LED_Write(!LED_Read()) ;

    }

}

===================

If this still exceeds 100ms, maybe it's time to consider the priority....

moto

ChHs_4614611
New Contributor II

Hi Moto,

My 100ms counter in SystemLed() function.

CY_ISR just set flag to true.

0 Likes
MotooTanaka
Esteemed Contributor

Hi,

> My 100ms counter in SystemLed() function.

> CY_ISR just set flag to true.

Yes, that is a correct usage of ISR, in general.

But in your case, if you want the LED blink not disturbed by other interrupt(s),

the safest approach I could think of was blink it inside the Timer ISR.

No mater how high priority you could set the interrupt,

the usual procedure in the main loop will be preempted by interrupts.

moto

MotooTanaka
Esteemed Contributor

Hi,

Have you had a chance to try below, which I wrote in my first response?

===================

volatile uint32_t led_tick_count = 0 ;

CY_ISR(SysTick_ISR)

{

    led_tick_count++ ;

    if ((led_tick_count % 100) == 0) {

        led_tick_count = 0 ;

        LED_Write(!LED_Read()) ;

    }

}

===================

moto

LinglingG_46
Moderator
Moderator

If it is the priority issue, please try to use the below API to change the NVIC priority:


    NVIC_SetPriority (CY_INT_SYSTICK_IRQN, (1UL << __NVIC_PRIO_BITS) - 2UL); // You can change the 2UL to (0,1,2,3,4)

    CySysTickStart();
   
    t= NVIC_GetPriority(CY_INT_SYSTICK_IRQN); // Get the t to judge whether it is successful to change the priority
   
     UART_PutHexByte(t); // use the debug interface to check the value

Hope it can be helpful for you!

View solution in original post

MotooTanaka
Esteemed Contributor

Dear LinglingG_46-san,

Thank you very much for the information!

> CY_INT_SYSTICK_IRQN

This is the information I was looking for about an hour last night but in vain.

So I modified my test program to see the priority of the SysTick.

000-TeraTerm-log.JPG

It seems that the priority is already 0 and I think this is the highest priority we can set, right?

So I'm afraid that there is not much we can do about making the priority of SysTick Higher.

I hope that my previous approach can soothe the situation...

Best Regards,

9-May-2020

Motoo Tanaka

ChHs_4614611
New Contributor II

Dear LinglingG_46-san,

Thank you for your information.

I will try it.

0 Likes