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.

C28335 ADC conversion fails



Hi,

I am working on a C28335 project. In my project the AD conversion seems to fail once in a while (between 15 minutes and an hour between failures). I am sampling at 1kHz, and the periodicity is controlled via a RTOS that I am running. Basically my ADC task resets a flag and fires the new conversion. The flag is then set by the ADC ISR if executed. The ADC task then checks the flag and reads the sample if successful.

Is this a normal behavior that I should just handle, or if I should put more effort into investigating the cause?

If this is an abnormal behavior it could have all sorts of explanations. Ranging from scheduling problems in the RTOS, to damaged HW (unfortunately I only have one board available for testing...). Investigating it could take a lot of time, but implementing error handling which handles the problem is very easy. Therefore it would be nice to have a second opinion before investing this any further.

Best regards

Johan

  • Hi Johan,

    Johan W���lger said:
    Is this a normal behavior that I should just handle, or if I should put more effort into investigating the cause?

    This is to get around the ADC first sample issue that exist in some of the C2000 MCUs, such as the F28027. 
    According to the Errata:


    Other than this case you should not face any issues!

    Johan W���lger said:
    In my project the AD conversion seems to fail once in a while (between 15 minutes and an hour between failures).

    Can you describe in detail how you're able to grab this ADC result? Using graphs?

    Regards,

    Gautam

  • Hi Gautam,

    Thank you for your reply.

    My interpretation of your answer is that this sporadic failure of AD conversion is not to be considered a normal behavior.

    I am working on a F28335, so I guess the problem you are referring to for the F28027 should not apply. Also, the problem I am having is not related to the converted values or the first value. This appears to occur spontaneously, and what happens is that 1ms after I have started the AD conversion, the ISR still has not been executed.

    This is what my ADC code looks like.

    In this case CPU_FRQ_150MHZ == 1. I trigger the conversion by calling ADCDrv_StartADC, wait for 1ms and then check if the conversion is done by calling boADCDrv_ADCReady. When the problem occurs, it looks like the ISR hasn't been executed, because boADCDrv_ADCReady returns false.

    /****************************************************************
    * Private defines
    ****************************************************************/
    #if (CPU_FRQ_150MHZ)     // Default - 150 MHz SYSCLKOUT
      #define ADC_MODCLK 0x3 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3)   = 25.0 MHz
    #endif
    #if (CPU_FRQ_100MHZ)
      #define ADC_MODCLK 0x2 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 100/(2*2)   = 25.0 MHz
    #endif
    #define ADC_CKPS   0x1   // ADC module clock = HSPCLK/2*ADC_CKPS   = 25.0MHz/(1*2) = 12.5MHz
    #define ADC_SHCLK  0xf   // S/H width in ADC module periods                        = 16 ADC clocks
    
    /****************************************************************
    * Private function prototypes
    ****************************************************************/ 
    interrupt void ADCDrv_ISR(void);
    
    /****************************************************************
    * Private global variables
    ****************************************************************/	
    static uint16_t m_boChannelsUpdated;
    
    /************************************************************************************
    * Initialize the ADC
    *************************************************************************************/
    void ADCDrv_InitADC(void)
    {	
    	/* Specific clock setting */
       	EALLOW;
        SysCtrlRegs.HISPCP.all = ADC_MODCLK;	/* HSPCLK = SYSCLKOUT/ADC_MODCLK */
        EDIS;
       
    	/* Init the ADC */
    	InitAdc();  
    	
        /* ADC timing setup */
        AdcRegs.ADCTRL1.bit.ACQ_PS = ADC_SHCLK;
        AdcRegs.ADCTRL3.bit.ADCCLKPS = ADC_CKPS;
          	
    	/* Configure ADC */
    	AdcRegs.ADCTRL1.bit.SEQ_CASC = 0x1; 	// Setup cascaded sequencer mode
       	AdcRegs.ADCMAXCONV.all = 0x000f;        // Setup 16 conv's
       	
    	AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0;  // Setup conv from ADCINA0  
    	AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x1;  // Setup conv from ADCINA1
    	AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0x2;  // Setup conv from ADCINA2
    	AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x3;  // Setup conv from ADCINA3
    	AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x4;  // Setup conv from ADCINA4
    	AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x5;  // Setup conv from ADCINA5
    	AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 0x6;  // Setup conv from ADCINA6
    	AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 0x7;  // Setup conv from ADCINA7
    	AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 0x8;  // Setup conv from ADCINB0
    	AdcRegs.ADCCHSELSEQ3.bit.CONV09 = 0x9;  // Setup conv from ADCINB1
    	AdcRegs.ADCCHSELSEQ3.bit.CONV10 = 0xA;  // Setup conv from ADCINB2
    	AdcRegs.ADCCHSELSEQ3.bit.CONV11 = 0xB;  // Setup conv from ADCINB3
    	AdcRegs.ADCCHSELSEQ4.bit.CONV12 = 0xC;  // Setup conv from ADCINB4
    	AdcRegs.ADCCHSELSEQ4.bit.CONV13 = 0xD;  // Setup conv from ADCINB5
    	AdcRegs.ADCCHSELSEQ4.bit.CONV14 = 0xE;  // Setup conv from ADCINB6
    	AdcRegs.ADCCHSELSEQ4.bit.CONV15 = 0xF;  // Setup conv from ADCINB7
    		
       	AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1;  	// Enable SEQ1 interrupt (every EOS)
        AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1;       /* Reset SEQ1 */
    
        /* Interrupt setup */
        EALLOW;
        PieVectTable.ADCINT = &ADCDrv_ISR;
        EDIS;
    
        IER |= M_INT1;
        PieCtrlRegs.PIEIER1.bit.INTx6 = 1;
    
        /* Reset channel status */
       	m_boChannelsUpdated = FALSE;
    }
    
    /************************************************************************************
    * Start the ADC sequence
    *
    *************************************************************************************/
    void ADCDrv_StartADC( void )
    {	
        m_boChannelsUpdated = FALSE;        /* Waiting for new sequence */
    	AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1;	/* Enable SOC to start SEQ1 */
    }
    
    
    bool_t boADCDrv_ADCReady( void )
    {
        return( m_boChannelsUpdated );
    }
    
    /************************************************************************************
    * The ISR for ADC
    *************************************************************************************/
    interrupt void ADCDrv_ISR( void )
    {
      	/* Reinitialize for next ADC sequence */
      	AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1;       /* Reset SEQ1 */
      	AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;     /* Clear INT SEQ1 bit */
      	PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; /* Acknowledge interrupt to PIE   */
    	
        m_boChannelsUpdated = TRUE;             /* SAmpled data now available */
    }

    Best regards,

    Johan

  • Johan,

    I have used the ADC on the F28335 on many projects in a way similar to what you have implemented, and never observed missed interrupts.

    Can you run the system in the debugger?  You could then investigate the state of the ADC when the condition occurs.  Did the sequence start?  Did it end?  Are any interrupt flags set (just not serviced somehow)?

    Regards,

    Bill

  • Thank you Bill,

    This is very useful information. Right now I can not run the system in the debugger because of a problem with booting a slave DSP when the F28335 is running in the debugger. Once that is solved I have a bunch of ideas about what could go wrong. I'm going to start looking at the timing of th RTOS. I wouldn't be surprised if what should be a 1ms period just isn't at the point where the ADC fails.

    What I needed most of all was an indication about whether this is a normal behavior that error handling should just deal with, or if there is reason to start investigating the cause.

    I will post my findings in this thread as soon as possible.

    Best regards,

    Johan