硬汉嵌入式论坛

 找回密码
 立即注册
查看: 916|回复: 2
收起左侧

[FreeRTOS] 细节问题,为什么pcInterruptPriorityRegisters设置地址0xE000E3F0,而不是0xE000E400

[复制链接]

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106721
QQ
发表于 2023-7-6 01:12:06 | 显示全部楼层 |阅读模式
首次看这里很容易不太理解,实际上这里有个隐含的问题,中断向量序号表前16个是系统中断。后面才是用户中断。

实际自己实现操作了下,才意识到这个问题,开始还以为是个bug:

#define portNVIC_IP_REGISTERS_OFFSET_16         ( 0xE000E3F0 )
static const volatile uint8_t * const pcInterruptPriorityRegisters = ( uint8_t * ) portNVIC_IP_REGISTERS_OFFSET_16;

ucCurrentPriority = pcInterruptPriorityRegisters[ ulCurrentInterrupt ]; -- 比较考验细节


[C] 纯文本查看 复制代码
	void vPortValidateInterruptPriority( void )
	{
	uint32_t ulCurrentInterrupt;
	uint8_t ucCurrentPriority;

		/* Obtain the number of the currently executing interrupt. */
		ulCurrentInterrupt = vPortGetIPSR();

		/* Is the interrupt number a user defined interrupt? */
		if( ulCurrentInterrupt >= portFIRST_USER_INTERRUPT_NUMBER )
		{
			/* Look up the interrupt's priority. */
			ucCurrentPriority = pcInterruptPriorityRegisters[ ulCurrentInterrupt ];

			/* The following assertion will fail if a service routine (ISR) for
			an interrupt that has been assigned a priority above
			configMAX_SYSCALL_INTERRUPT_PRIORITY calls an ISR safe FreeRTOS API
			function.  ISR safe FreeRTOS API functions must *only* be called
			from interrupts that have been assigned a priority at or below
			configMAX_SYSCALL_INTERRUPT_PRIORITY.

			Numerically low interrupt priority numbers represent logically high
			interrupt priorities, therefore the priority of the interrupt must
			be set to a value equal to or numerically *higher* than
			configMAX_SYSCALL_INTERRUPT_PRIORITY.

			Interrupts that	use the FreeRTOS API must not be left at their
			default priority of	zero as that is the highest possible priority,
			which is guaranteed to be above configMAX_SYSCALL_INTERRUPT_PRIORITY,
			and	therefore also guaranteed to be invalid.

			FreeRTOS maintains separate thread and ISR API functions to ensure
			interrupt entry is as fast and simple as possible.

			The following links provide detailed information:
			[url]http://www.freertos.org/RTOS-Cortex-M3-M4.html[/url]
			[url]http://www.freertos.org/FAQHelp.html[/url] */
			configASSERT( ucCurrentPriority >= ucMaxSysCallPriority );
		}

		/* Priority grouping:  The interrupt controller (NVIC) allows the bits
		that define each interrupt's priority to be split between bits that
		define the interrupt's pre-emption priority bits and bits that define
		the interrupt's sub-priority.  For simplicity all bits must be defined
		to be pre-emption priority bits.  The following assertion will fail if
		this is not the case (if some bits represent a sub-priority).

		If the application only uses CMSIS libraries for interrupt
		configuration then the correct setting can be achieved on all Cortex-M
		devices by calling NVIC_SetPriorityGrouping( 0 ); before starting the
		scheduler.  Note however that some vendor specific peripheral libraries
		assume a non-zero priority group setting, in which cases using a value
		of zero will result in unpredictable behaviour. */
		configASSERT( ( portAIRCR_REG & portPRIORITY_GROUP_MASK ) <= ulMaxPRIGROUPValue );
	}

评分

参与人数 1金币 +20 收起 理由
会飞的猪_2020 + 20 很给力!

查看全部评分

回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106721
QQ
 楼主| 发表于 2023-7-6 01:13:44 | 显示全部楼层

NVIC中断优先级配置起始地址0xE000E400

下载 (12).png
回复

使用道具 举报

39

主题

196

回帖

323

积分

高级会员

积分
323
发表于 2024-3-14 11:49:00 | 显示全部楼层
我全局搜了Cortex-M3的手册,没找到0xE000E3F0,也奇怪呢。
硬汉哥的帖子给我解惑了。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-5-1 06:21 , Processed in 0.262059 second(s), 32 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表