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.

F28M35 C28 core : Using in the main process 16 and 32 bits variables modified by an interrupt

Hello,

Here is a sample code:

Uint16 Var16bits, Var16bitsModifiedByInterrupt;

Uint32 Var32bits, Var32bitsModifiedByInterrupt;

main(){

...

while(1){

Var16bits = Var16bitsModifiedByInterrupt;

...

Var32bits = Var32bitsModifiedByInterrupt;

...

}

}//End main

I have a periodic interrupt EPWM1_INT which modified Var16bitsModifiedByInterrupt, and Var32bitsModifiedByInterrupt.

- 1) I think that for Var16bitsModifiedByInterrupt, i don't have to disable the interrupt. Is it correct ?

- 2) I think that for Var32bitsModifiedByInterrupt, i must disable the interrupt. Is it correct ?

- 3) If I disable for a "short time" the interrupt  EPWM1_INT and the flag of the interrupt is set during this "short time", will this occurence of the interrupt be lost or simply offset ?

Thanks

  • Joel,

    You don't have to disable interrupts to read either of the variables. 32-bit RAM reads complete in a single cycle. Even multi-cycle instructions should complete before the interrupt is taken. This is explained in the C28x Reference Guide (SPRU430e) section 4.1.1:

    -----
    Instructions in their fetch 1, fetch 2, and decode 1 phases are discarded if an
    interrupt or other program-flow discontinuity occurs. An instruction that reaches
    its decode 2 phase always runs to completion before any program-flow
    discontinuity is taken.
    -----

    You can always check your assembly to verify that the read has been compiled into a single MOVL instruction. The compiler should make sure that all C variables are aligned correctly.

    If you disable interrupts for a short time, any flagged interrupts will be taken when interrupts are re-enabled.