- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Moto,
My 100ms counter in SystemLed() function.
CY_ISR just set flag to true.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear LinglingG_46-san,
Thank you for your information.
I will try it.