1

我的代码遇到了一个相当奇怪的问题,其中我有一个在 main 中初始化的值。一旦我尝试在中断中调用该变量,它就是 0。我在这里缺少什么?不同的变量是否存在于中断中?

我想指出,这是一个关于中断的更具理论性的问题,以及我是否不能在空闲和中断之间共享值。

Supervisor supervisor;
XScuTimer TimerInstance;
XScuGic IntcInstance;
uint32_t offset;

void interruptRoutine(void *CallBackRef) {

    // Define pointer to timer
    XScuTimer *TimerInstancePtr = (XScuTimer *) CallBackRef;

    // If timer is expired, clear interrupt status
    if (XScuTimer_IsExpired(TimerInstancePtr)) {
        XScuTimer_ClearInterruptStatus(TimerInstancePtr);

        // Why is offset 0 within the interrupt routine?
        xil_printf("Interrupt: %u\n", offset);

    }

}

//.. I omitted the interrupt init method ..//

int main() {

    while (true) {
        // Get all sensor data
        offset = 1;

    }

}
4

0 回答 0