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.

TMS320F28069M: Reading 3 adc inputs using CLA, attempting to save values to arrays for each input.

Part Number: TMS320F28069M

I have had some trouble with the CLA in regards to reading ADC values. I started my code based off of the ClaAdc example which originally, as taken from the comments "Cla Task2 logs 20 ADCRESULT1 values in a circular buffer."

I first adapted this example to read 3 adc values into simple integer variables, I then tried to store these values in 3 (adc) x 5 (array size) arrays, and this is where I ran into trouble. The values in the 1st position of each array would update, however the value would not increment. I also tried adjusting the frequency of cla interrupts called, but this did not have any affect. The cla code is posted below.

    MMOVZ16    MR0,  @_ConversionCount                           ;1 Current Conversion

    MMOV16     MAR0, MR0, #_VoltageA                                ;2 Point MAR0 register to VoltageA[ConversionCount]

    MMOV16     MAR1, MR0, #_VoltageB                                ;2 Point MAR1 register to VoltageB[ConversionCount]

    MNOP                                                                                 ; wait

    MNOP                                                                                 ; wait

    MNOP                                                                                 ;5 wait

    MNOP                                                                                ;6 wait

    MNOP                                                                                ;7 Wait till I8 to read result

    MMOVZ16    MR2,  @_AdcResult.ADCRESULT0            ;8 Read ADCRESULT0

    MMOV16     *MAR0, MR2                                                 ;9 Store ADCRESULT0 using pointer to VoltageA[ConversionCount]

    MMOV16     MAR0, MR0, #_VoltageC                              ;10 Point MAR0 to VoltageC[ConversionCount], need to do this now because we can't access this register for another 5 cycles

    MMOVZ16    MR2,  @_AdcResult.ADCRESULT1            ;  Read ADCRESULT1

    MMOV16     *MAR1, MR2                                                 ;  Store ADCRESULT1 in VoltageB[ConversionCount]

    MUI16TOF32 MR0, MR0                                                  ; need to wait, but convert to float now

    MMOVZ16    MR2,  @_AdcResult.ADCRESULT2           ;9 Read ADCRESULT2

    MMOV16     *MAR0, MR2                                                ;  Store ADCRESULT2 to VoltageC[ConversionCount]

    MADDF32   MR0, MR0, #1.0                                            ; Add 1 to ConversionCount

    MCMPF32    MR0, #NUM_DATA_POINTS.0                    ; Compare ConversionCount to max

    MF32TOUI16 MR0, MR0                                                  ; Convert count to Uint16

    MBCNDD     _RestartCount, GEQ                                    ; If count >= NUM_DATA_POINTS

    MMOVIZ     MR1, #0.0                                                       ; Preload MR1 with 0

    MNOP

    MNOP

    MMOV16     @_ConversionCount, MR0                           ; If branch not taken, store current count

    MSTOP

_RestartCount

    MMOV16     @_ConversionCount, MR1                          ; If branch taken, restart count

    MSTOP

    MNOP

    MNOP

    MNOP

_Cla1T2End:

  • Luke Smith16 said:
        MCMPF32    MR0, #NUM_DATA_POINTS.0                    ; Compare ConversionCount to max
        MF32TOUI16 MR0, MR0                                                  ; Convert count to Uint16
        MNOP
        MNOP
        MBCNDD     _RestartCount, GEQ                                    ; If count >= NUM_DATA_POINTS

    The branch can only be affected by an instruction threee cycles prior. So the MCMPF32 needs to be the fourth instruction prior to the branch 

    Also, what is the address of conversionCount? is it in a CLA data memory? How is it declared in the assembly file?