• freertos的任务调度器的启动函数分析(根据源码使用)


    volatile uint8_t * const pucFirstUserPriorityRegister = ( uint8_t * ) ( portNVIC_IP_REGISTERS_OFFSET_16 + portFIRST_USER_INTERRUPT_NUMBER );

    通过宏pucFirstUserPriorityRegister=0xE000E400(根据宏名字,这是NVIC寄存器地址)

    查手册知到

    中断优先级设置寄存器的第一个寄存器。

    ulOriginalPriority = *pucFirstUserPriorityRegister;保存第一个寄存器的值

    获取寄存器有效位。

    ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;

    #define configMAX_SYSCALL_INTERRUPT_PRIORITY   \

     ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )

    configMAX_SYSCALL_INTERRUPT_PRIORITY=(5<<(8-4))

    ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;//为7

       while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE )

            {//portTOP_BIT_OF_BYTE=0x80

            /*有几个有效位,就执行几次*/

                ulMaxPRIGROUPValue--;//最后的值为7-4

                ucMaxPriorityValue <<= ( uint8_t ) 0x01;

            }

            /* Shift the priority group value back to its position within the AIRCR

            register. *///注释表明,将得到的值填入AIRCR寄存器,来确定如何分组。

            ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT;//3左移8位

            ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK;//仅保留3左移8位后的位为1

    这里3左移8位,然后填入PRIGROUP;

        /* Make PendSV and SysTick the lowest priority interrupts. */因为用4位表示优先级,所以这里是15。

        portNVIC_SYSPRI2_REG |= portNVIC_PENDSV_PRI;

        portNVIC_SYSPRI2_REG |= portNVIC_SYSTICK_PRI;

        void vPortSetupTimerInterrupt( void )

    {

            /* Configure SysTick to interrupt at the requested rate. *///产生指定周期的中断

            portNVIC_SYSTICK_LOAD_REG =

    ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;

            portNVIC_SYSTICK_CTRL_REG =

    ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );

    }

    __asm void prvStartFirstTask( void )

    {

        PRESERVE8

        /* Use the NVIC offset register to locate the stack. */

        ldr r0, =0xE000ED08

        ldr r0, [r0]

        ldr r0, [r0]

        /* Set the msp back to the start of the stack. */

        msr msp, r0

        /* Globally enable interrupts. */

        cpsie i

        cpsie f

        dsb

        isb

        /* Call SVC to start the first task. */

        svc 0

        nop

        nop

    }

  • 相关阅读:
    asp.net core在发布时排除配置文件
    聊聊Go里面的闭包
    Redis实战精讲(1)
    Unity VR开发教程 OpenXR+XR Interaction Toolkit 2.1.1 (六)手与物品交互(触摸、抓取)
    AI大模型重塑新媒体变现格局:智能写作技术助力腾飞!
    PPT转PDF转换器:便捷的批量PPT转PDF转换软件
    pandas merge 和 concat
    天地图全国幼儿园数据下载与处理分析
    【机器学习算法】关联规则2 FPgrowth法算法
    快速筛选打卡时间日期等数据:EXCEL筛选查找某一时间点是否在某一时间段内
  • 原文地址:https://blog.csdn.net/m0_54797575/article/details/133388335