lm3s 把中断放在ram中,对NVIC_VTABLE赋值时错误

2019-03-24 14:02发布

  1. void
    IntRegister(unsigned long ulInterrupt, void (*pfnHandler)(void))
    {
    unsigned long ulIdx, ulValue;

    //
    // Check the arguments.
    //
    ASSERT(ulInterrupt < NUM_INTERRUPTS);
    // Make sure that the RAM vector table is correctly aligned.
    //
    ASSERT(((unsigned long)g_pfnRAMVectors & 0x000003ff) == 0);

    //
    // See if the RAM vector table has been initialized.
    //
    if(HWREG(NVIC_VTABLE) != (unsigned long)g_pfnRAMVectors)
    {
    // Copy the vector table from the beginning of FLASH to the RAM vector
    // table.
    //
    ulValue = HWREG(NVIC_VTABLE);
    for(ulIdx = 0; ulIdx < NUM_INTERRUPTS; ulIdx++)
    {
    g_pfnRAMVectors[ulIdx] = (void (*)(void))HWREG((ulIdx * 4) +
    ulValue);
    }

    //
    // Point NVIC at the RAM vector table.
    //

    HWREG(NVIC_VTABLE) = (unsigned long )(g_pfnRAMVectors+8);
    }
    // Save the interrupt handler.
    g_pfnRAMVectors[ulInterrupt] = pfnHandler;
    }
复制代码
向量表的地址 向量表的地址
NVIC_VTABLE的内容,与向量表地址不同。 NVIC_VTABLE的内容,与向量表地址不同。
上面是函数 那个+8是我自己加上的,加和不加都一样,NVIC_VTABLE始终是20000380.为什么 此帖出自小平头技术问答
0条回答

一周热门 更多>

相关问题

    相关文章