Цитата(ViKo @ Apr 26 2012, 08:29)

Насчет сдвигов, по-моему, sysel не прав, и ничего сдвигать не нужно (потому и работает на любом процессоре, независимо от количества битов в регистрах приоритета):
As with other priority-level registers, the formatting of the BASEPRI register is affected
by the number of implemented priority register widths. For example, if only 3 bits are imple-
mented for priority-level registers, BASEPRI can be programmed as 0x00, 0x20, 0x40 … 0xC0,
and 0xE0
Как раз в этом примете "0x00, 0x20, 0x40 … 0xC0, and 0xE0" и получаем 3 бита приоритета сдвинуты на 5 влево. т.е. значение "0x60" регистра BASEPRI будет соответствовать значению 0x03 в NVIC_SetPriority().
Посмотрите реализацию "NVIC_SetPriority()". Они там сдвигают аргумента на (8 - __NVIC_PRIO_BITS) влево.
Из файла
LPC17xx.hКод
#define __NVIC_PRIO_BITS 5 /*!< Number of Bits used for Priority Levels */
Из файла
core_cm3.hКод
static __INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
{
if(IRQn < 0) {
SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for Cortex-M System Interrupts */
else {
NVIC->IP[(uint32_t)(IRQn)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for device specific Interrupts */
}
На самом деле в ядре Cortex-M3 всё логично получается, просто небольшая путанка в CMSIS-ке.