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/MSP432E411Y: fast ADC conversion

Part Number: MSP432E411Y
Other Parts Discussed in Thread: SYSBIOS

Tool/software: Code Composer Studio

Hello I want to convert multiple ADC to high speed.

As a result of checking the current 4 ADCs using ADCBuf, when set to Freq 1000, the conversion is good.

However, I want to convert to about 10us fast. (All four will be converted to 10us)

The code is set as follows.

ADCSAMPLESIZE = 1

    ADCBuf_init();
    sem_init(&adcbufSem, 0, 0);

    ADCBuf_Params_init(&adcBufParams);
    adcBufParams.callbackFxn = adcBufCallback;
    adcBufParams.recurrenceMode = ADCBuf_RECURRENCE_MODE_CONTINUOUS;
    adcBufParams.returnMode = ADCBuf_RETURN_MODE_CALLBACK;
    adcBufParams.samplingFrequency = 100000;
    adcBuf = ADCBuf_open(CONFIG_ADCBUF_0, &adcBufParams);

    continuousConversion1.arg = NULL;
    continuousConversion1.adcChannel = CONFIG_ADCBUF_0_CHANNEL_0;
    continuousConversion1.sampleBuffer = sequencer0BufferOne;
    continuousConversion1.sampleBufferTwo = sequencer0BufferTwo;
    continuousConversion1.samplesRequestedCount = ADCSAMPLESIZE;

    continuousConversion2.arg = NULL;
    continuousConversion2.adcChannel = CONFIG_ADCBUF_0_CHANNEL_1;
    continuousConversion2.sampleBuffer = sequencer1BufferOne;
    continuousConversion2.sampleBufferTwo = sequencer1BufferTwo;
    continuousConversion2.samplesRequestedCount = ADCSAMPLESIZE;

    continuousConversion3.arg = NULL;
    continuousConversion3.adcChannel = CONFIG_ADCBUF_0_CHANNEL_2;
    continuousConversion3.sampleBuffer = sequencer2BufferOne;
    continuousConversion3.sampleBufferTwo = sequencer1BufferTwo;
    continuousConversion3.samplesRequestedCount = NULL;

    continuousConversion4.arg = NULL;
    continuousConversion4.adcChannel = CONFIG_ADCBUF_0_CHANNEL_3;
    continuousConversion4.sampleBuffer = sequencer3BufferOne;
    continuousConversion4.sampleBufferTwo = sequencer3BufferTwo;
    continuousConversion4.samplesRequestedCount = ADCSAMPLESIZE;

        if (ADCBuf_convert(adcBuf, &continuousConversion1, 1) != ADCBuf_STATUS_SUCCESS) {while(1);}
        if (ADCBuf_convert(adcBuf, &continuousConversion2, 1) != ADCBuf_STATUS_SUCCESS) {while(1);}
        if (ADCBuf_convert(adcBuf, &continuousConversion3, 1) != ADCBuf_STATUS_SUCCESS) {while(1);}
        if (ADCBuf_convert(adcBuf, &continuousConversion4, 1) != ADCBuf_STATUS_SUCCESS) {while(1);}

Call Back

void adcBufCallback(ADCBuf_Handle handle, ADCBuf_Conversion *conversion,
    void *completedADCBuffer, uint32_t completedChannel, int_fast16_t status) {
    uint_fast16_t i;
    uint16_t *completedBuffer = (uint16_t *) completedADCBuffer;

    for (i = 0; i < ADCSAMPLESIZE; i++)
    {
        outputBuffer[completedChannel][0] = completedBuffer[0];
    }

    if(completedChannel == CONFIG_ADCBUF_0_CHANNEL_3)
    {
        sem_post(&adcbufSem);
        m++;
    }
}

Is there a way to convert it to high speed?

  • Hi 

    Please refer to this demo that with DMA will increase the conversion speed

     

  • I checked the example and confirmed that it works well.

    I checked that Tcpip source which is another Ti example also works well.

    However, if I combine the two sources, that will have a hardfault.

    It happens when tcpecho source puts the adc usage code in tcpecho as it is.

    Can I ask for advice on why? Is it because of using driverlib.h in RTOS?

    ti_sysbios_family_arm_m3_Hwi_excHandlerAsm__I:
            .asmfunc
            tst     lr, #4          ; context on PSP?
            ite     NE
            mrsne   r0, psp         ; if yes, then use PSP
            moveq   r0, sp          ; else use MSP

            mov     sp, r0          ; use this stack
            stmfd   sp!, {r4-r11}   ; save r4-r11 while we're at it
            mov     r0, sp          ; pass sp to exception handler
            mov     r1, lr          ; pass lr too
            mov     r4, lr          ; preserve LR in r4

            ldr     r2, excHandlerAddr
            blx     r2

            mov     r0, sp          ; for ROV
            mov     r1, r4          ; for ROV
    $1
            b       $1              ; spin here indefinitely --> Error!!

  • Hi 

    Are you sure you use the demo I send to you that use timer trigger ADC directly without ISR and move the result by DMA also without ISR. That means it is not interrupted by the CPU. Or could you make sure if any peripheral configure conflict between the two demos? Like use same timer or GPIO pins or DMA channels some like that.

  • hi!

    The ADC example code is TimerA, so I changed it to TimerB. The above error does not appear, but the ADC's Handler does not seem to be working.

    1.  I want to operate 7 ADC with 10us cycle.

        MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
        while(!(MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_TIMER0)))
        {
        }

        MAP_TimerConfigure(TIMER0_BASE, TIMER_CFG_B_PERIODIC);
        MAP_TimerLoadSet(TIMER0_BASE, TIMER_B, 1200); <- I know that RTOS operates at 120MHz. Is this right?
        MAP_TimerADCEventSet(TIMER0_BASE, TIMER_ADC_TIMEOUT_B);
        MAP_TimerControlTrigger(TIMER0_BASE, TIMER_B, true);
        MAP_TimerEnable(TIMER0_BASE, TIMER_B);

    2. Is there anything special that RTOS needs to do to operate the next Handler?

    void ADC0SS1_IRQHandler(void)
    {
        uint32_t getIntStatus;

        getIntStatus = MAP_ADCIntStatusEx(ADC0_BASE, true);
        if((getIntStatus & ADC_INT_DMA_SS1) == ADC_INT_DMA_SS1)
        {
            MAP_ADCIntClearEx(ADC0_BASE, ADC_INT_DMA_SS1);
            MAP_uDMAChannelTransferSet(UDMA_CH15_ADC0_1 | UDMA_PRI_SELECT, UDMA_MODE_BASIC, (void *)&ADC0->SSFIFO1, (void *)&srcBuffer_SS1,sizeof(srcBuffer_SS1)/2);
            MAP_uDMAChannelEnable(UDMA_CH15_ADC0_1);

            bgetConvStatus = true;
        }
    }

    3. Break Point does not get on ADC0SS1 _ IRQHandler. Why is this? (All ways, Disable.)

  • Hi 

    Have you try the code without RTOS?

  • hi.

    I had to use rtos to use tcpip, so I had to combine two. I did not use rtos, but I tried uart and adc and confirmed that uart is slow and data loss.

  • Hi

    Have you solve your problem?

**Attention** This is a public forum