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.

CCS/MSP430FR5739: Wrong ADC10 results in the memory

Part Number: MSP430FR5739
Other Parts Discussed in Thread: MSP-EXP430FR5739

Tool/software: Code Composer Studio

Dear Community,

I use nearly the software example from the demo code:

CCS8.2/MSP430FR5739/DMA(64)-ADC10

And I like the use of nearly the full 16Bit room (64*1023=65472) and no overflow should happen.

The point is, overflow happens many times and looking at the register values explains this.

For example: ADC10result[20] = 7651. How can the ADC10 Module generate values higher like 1023?

Can someone give me a hint?

Sincerely

Volker

  • Hi Volker,

    could you please share your code, that we could have a look at the problem.

  • Here  is the part of the ADC code:

    unsigned int ADC_Result[64];
    unsigned int k;
    unsigned int ADC_Result_sum;

      // Configure ADC10 - pulse sample mode; software trigger;
      ADC10CTL0 = ADC10SHT_2 + ADC10ON + ADC10MSC; // 16ADCclks, ADC on
      ADC10CTL1 = ADC10SHP + ADC10CONSEQ_2;     // pulse sample mode, rpt single ch
      ADC10CTL2 = ADC10RES;                     // 10-bits of resolution
    //  ADC10MCTL0 = ADC10INCH_1;                 // AVCC ref, A1
      ADC10HI = 950;                 // Window Comparator Hi-threshold
      ADC10LO = 75;                  // Window Comparator Lo-threshold

      // Configure DMA (ADC10IFG trigger)
      DMACTL0 = DMA0TSEL__ADC10IFG;                     // ADC10IFG trigger
      __data16_write_addr((unsigned short) &DMA0SA,(unsigned long) &ADC10MEM0);
                                                // Source single address
      __data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &ADC_Result[0]);
                                                // Destination array address
      DMA0SZ = 66;                              // 64 conversions
      // Rpt, inc dest, word access,
      DMA0CTL = DMADT_4 + DMADSTINCR_3 + DMAEN + DMAIE + DMALEVEL;
                                             // enable int after 66 conversions


    // In while loop:

    if (DMA64ISR)
          {
              ADC_Result_sum = 0x0;                   // clear accumulate register
              for(k=2;k<66;k++) {                      // BREAKPOINT HERE; View ADC_Result
              ADC_Result_sum += ADC_Result[k];
              }
              DMA64ISR = 0;
              sumreddy = 1;
          }
    if (ADCSW)
          {
              DMA0CTL |=DMAEN + DMAIE;   // DMA-ADC-Routine
              ADC10CTL0 |= ADC10ENC + ADC10SC;        // Sampling and conversion start
              ADCSW = 0;
          }

    // Call in UART - fuction example:

    else if ((c_Befehl[1]=='I') | (c_Befehl[1]=='i'))
        {

        //Auslesen des Motorstroms
        ADC10CTL0 &= ~ADC10ENC;
        ADC10MCTL0 = ADC10INCH_13;                 // AVCC ref, A13
        ADC = 13;
        ADCSW = 1;
        return;
        }

    // Part in the IRQ :


    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=DMA_VECTOR
    __interrupt void DMA0_ISR (void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(DMA_VECTOR))) DMA0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
      switch(__even_in_range(DMAIV,16))
      {
        case  0: break;                          // No interrupt
        case  2:
          // 64 conversions complete
          ADC10CTL0 &= ~ADC10ENC;
          DMA64ISR = 1;     // start sum
          break;                                 // DMA0IFG
        case  4: break;                          // DMA1IFG
        case  6: break;                          // DMA2IFG
        case  8: break;                          // Reserved
        case 10: break;                          // Reserved
        case 12: break;                          // Reserved
        case 14: break;                          // Reserved
        case 16: break;                          // Reserved
        default: break;
      }
    }

  • Hi Volker,

    Sorry for reply late.

    I reviewed your code and found you declared the ADC_Result[64] for unsigned int type(16 bit by default). But you changed the type to unsigned long(32 bit by default) in the DMA configuration. You may change your declaration of ADC_Result[64] to unsigned long(32 bit) which aligns with your code in DMA part. Please let me know your test result after updating the declaration.

    BTW, I have tried you code on MSP-EXP430FR5739 and it showed no ADC result out of 0x3FF.

  • Hi thank you very much for answering,

    I just have copied the DMA example (without understanding the code ;-) ) and they are using it in the same way.

    I will try and give you feedback

    Volker

  • Hi Volker,

    Thanks for reply. Please feel free to come back when you get any update.

    If this thread locks, please click the "Ask a related question" button and in the new thread describe the current status of your issue and any additional details you may have to assist us in helping to solve your issues.

**Attention** This is a public forum