This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

msp432中断优先级设置



MAP_Interrupt_setPriority(INT_TA0_0, 0x44);
MAP_Interrupt_setPriority(INT_TA3_0, 0x50); 
请问目前msp432,设置定时器A0的优先级高于定时器A3,但是在单片机运行时,常常出现定时器A0中断来时,无法马上从定时器A3中断中退出
  • 不太清楚,其他的优先级数被使用了吗,如果没有换0x20和0x40试试看,我看官方例子是用的这两个。
  • "The hardware priority mechanism only looks at the upper N bits of the priority level (where N is 3 for the MSP432 family), so any prioritization must be performed in those bits. The remaining bits can be used to sub-prioritize the interrupt sources, and may be used by the hardware priority mechanism on a future part".

    所以有效的优先级分配是类似下面这样

    Interrupt_setPriority(interrupt_number_1,0x00); //最高优先级
    Interrupt_setPriority(interrupt_number_2,0x20);
    Interrupt_setPriority(interrupt_number_3,0x40);
    Interrupt_setPriority(interrupt_number_4,0x60);
    Interrupt_setPriority(interrupt_number_5,0x80);
    Interrupt_setPriority(interrupt_number_6,0xA0);
    Interrupt_setPriority(interrupt_number_7,0xC0);
    Interrupt_setPriority(interrupt_number_8,0xE0); //最低优先级
  • MAP_Interrupt_setPriority(INT_PORT6, 0x40);//key
    MAP_Interrupt_setPriority(INT_ADC14, 0x60);
    MAP_Interrupt_setPriority(INT_EUSCIA0, 0x20);
    MAP_Interrupt_setPriority(INT_EUSCIA1, 0x20);//UART
    MAP_Interrupt_setPriority(INT_EUSCIA3, 0x20);//flash
    MAP_Interrupt_setPriority(INT_EUSCIB0, 0x20); //Empprom
    MAP_Interrupt_setPriority(INT_PORT2, 0x80);
    MAP_Interrupt_setPriority(INT_RTC_C, 0xE0);
    MAP_Interrupt_setPriority(INT_WDT_A, 0xC0);
    在重新分配有效的优先级后,发现在程序运行时,部分全局变量会突变;
    debug发现定义的bool g_TempType=false;extern bool g_TempType;
    Watch窗口的值g_TempType=0x88;
    是不是由于定义的堆栈空间不足引起的?

    以下是我的堆栈分配情况:
    "A0": place at 0x00000000 { ro section .intvec };
    "P1": place in [from 0x00000000 to 0x0003ffff] |
    [from 0x00200000 to 0x00203fff] { ro };
    define block CSTACK with size = 12K, alignment = 8 { };
    define block HEAP with size = 8K, alignment = 8 { };
    "P3": place in [from 0x01000000
    to 0x0100ffff
    repeat 2
    displacement 0x1f000000] { rw, block CSTACK, block HEAP };
    do not initialize { section .noinit };
    initialize by copy { rw };

    No sections matched the following patterns:

    ro section application_specific_ro in "P2|P4"
    rw section application_specific_rw in "P2|P4"
  • 你自己修改了默认的堆栈配置?用官方默认的试试看。
  • 用官方默认堆栈配置,试了仍然无法解决,全局变量被覆盖问题;
    "A0": place at 0x00000000 { ro section .intvec };
    "P1": place in [from 0x00000000 to 0x0003ffff] |
    [from 0x00200000 to 0x00203fff] { ro };
    define block CSTACK with size = 8K, alignment = 8 { };
    define block HEAP with size = 16K, alignment = 8 { };
    "P3": place in [from 0x01000000
    to 0x0100ffff
    repeat 2
    displacement 0x1f000000] { rw, block CSTACK, block HEAP };
    do not initialize { section .noinit };
    initialize by copy { rw };
  • 这个中断优先级的解决了没,之前那个全局变量被串改的事情解决了没,是什么原因引起的?