Hi
I am working porting chibios to a new chipset with M0 core, and when I tried to change systick priority, it didn't work. Fortunately, I use Keil and replaced "nvicSetSystemHandlerPriority(HANDLER_SYSTICK, SN32_ST_IRQ_PRIORITY)" with CMSIS API "NVIC_SetPriority(-1, SN32_ST_IRQ_PRIORITY)", then it worked.
I traced the registers value with follow code snippet:
LOG_TRACE("SCB->SHP: %08x, %08x\r\n", SCB->SHP[0], SCB->SHP[1]);
I found that "nvicSetSystemHandlerPriority" set SHP[0] register and "NVIC_SetPriority" set SHP[1].
According to m0 document, the SHP[0] should be SHPR2, and SHP[1] shoudl be SHPR3, it seem that "nvicSetSystemHandlerPriority" doesn't set the register corretly.
There is another post 2 years ago, should be same problem:
viewtopic.php?f=35&t=5268
NVICSetSystemHandlerPriority doesn't work correctly on m0 platform Topic is solved
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: NVICSetSystemHandlerPriority doesn't work correctly on m0 platform Topic is solved
Hi,
Found the problem it was a missing check but the code was correct....
Before:
after:
It failed if the core was CM0+ but worked for CM0 and CM23.
Fixed as bug #1199.
Giovanni
Found the problem it was a missing check but the code was correct....
Before:
Code: Select all
#if defined(__CORE_CM0_H_GENERIC) || defined(__CORE_CM23_H_GENERIC)
SCB->__SHPR[_SHP_IDX(handler)] = (SCB->__SHPR[_SHP_IDX(handler)] & ~(0xFFU << _BIT_SHIFT(handler))) |
(NVIC_PRIORITY_MASK(prio) << _BIT_SHIFT(handler));
after:
Code: Select all
#if defined(__CORE_CM0_H_GENERIC) || defined(__CORE_CM0PLUS_H_GENERIC) || \
defined(__CORE_CM23_H_GENERIC)
SCB->__SHPR[_SHP_IDX(handler)] = (SCB->__SHPR[_SHP_IDX(handler)] & ~(0xFFU << _BIT_SHIFT(handler))) |
(NVIC_PRIORITY_MASK(prio) << _BIT_SHIFT(handler));
It failed if the core was CM0+ but worked for CM0 and CM23.
Fixed as bug #1199.
Giovanni
Who is online
Users browsing this forum: Bing [Bot] and 30 guests