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.

CLAdcFir example

I am puzzled by following lines of code in CLA_FIR.asm in example "Example_2803xClaAdcFir".

    MUI16TOF32 MR2,  @_AdcResult.ADCRESULT1  ;8 Read ADCRESULT1 and convert to float

    MMPYF32    MR2, MR1, MR0                 ; MR2 (Y) = MR1 (A4) * MR0 (X4)
 || MMOV32     @_X0, MR2

 

Are you not overwritting MR2 and losing adc result ?

  • sunil barot said:

        MUI16TOF32 MR2,  @_AdcResult.ADCRESULT1  ;8 Read ADCRESULT1 and convert to float

        MMPYF32    MR2, MR1, MR0                 ; MR2 (Y) = MR1 (A4) * MR0 (X4)
     || MMOV32     @_X0, MR2

     

    Are you not overwritting MR2 and losing adc result ?

    Sunil,

    This is a parallel operation (one instruction, two operations).  The MOV32 portion of the instruction will grab the MR2 value before the multiply updates it.   Therefore the value of MR2 before the multiply will be stored in X0. 

        MMPYF32    MR2, MR1, MR0                 ; MR2 (Y) = MR1 (A4) * MR0 (X4)
     || MMOV32     @_X0, MR2                          ; stores value of MR2 *before* multiply

     

    If the code was written like this (no parallel bars), then it becomes two separate instructions.   In this case the value of MR2 would  be updated by the multiply before the MOV instruction stores it.

        MMPYF32    MR2, MR1, MR0                 ; MR2 (Y) = MR1 (A4) * MR0 (X4)
        MMOV32     @_X0, MR2                          ; Stores value of MR2 after multiply

    Parallel instructions are described in section 5.3 of the TMS320x2803x Piccolo Control Law Accelerator (CLA) ref guide www.ti.com/lit/spruge6

    Regards

    -Lori

  • Thank you Lori,

    I must however state that it is not so clear in the guide that the instruction after "||" is executed first.

    sunil

  • Sunil,

    Thank you for the feedback.  I took a look at the guide and agree with you.  We'll take your feedback for the next release of the guide.

    Cheers

    -Lori