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.

AM2634: configure EDMA to transfer ADC reuslts in FREERTOS environment

Part Number: AM2634
Other Parts Discussed in Thread: SYSCONFIG

Hello, 

Currently I'm working on the configuration of EDMA to auto-transfer the result of ADC triggered by ADCINT with FREERTOS.

What I have done is as below:

1) Imported r5fss0-0_freertos project, and then in task_main, several periodic tasks, i.e. 1ms, 10ms, 100ms are created, it works well,

2) in task_main configured EPWM0 to trigger ADC0 SOC periodically, and in adc_app_ISR triggerd by EOC, the converted results are read by calling API ADC_readResult(), it works well.

The problem comes after:

3) I tried to add EDMA channel to transfer the result, I use almost the same configuration as in example adc_soc_continuous_dma, however, it doesn't work. The destination buffer is never updated.

I checked the register TPCC0, it looks the value of edmaParam is written correctly.

I tried to create edmaParam1, edmaParam2 and call API to link these two parameters, still not work.

what is worse, if I use following code to resister an interrupt function of DMA, the software will enter an abort, where I can't locate where the software is blocked during debuging. Without this interrupt register, the software can run, with EPWM and ADC working but DMA not woking.

/* Register interrupt */
intrObj.tccNum = tccAlloc0;
intrObj.cbFxn = &App_dmach0ISR;
intrObj.appData = (void *) &gEdmaTransferDoneSem;

status = EDMA_registerIntr(gEdmaHandle[0], &intrObj);
DebugP_assert(status == SystemP_SUCCESS);

 

My question is:

1) Is there an example implementing similar function to transfer ADC result using EDMA with FREERTOS running?

2) How to figure this issue out, where should I check to see if I miss something or everything is configured correctly?

3) Is it possible because of the conflict between several interrupts (adc_isr, dma_isr, RTI0) bringing the issue? Should I configure the priority of interrupts and how to make it through SysConfig?

Thanks a lot for your reply.

Lync

  • Hi Lync

    1) Is there an example implementing similar function to transfer ADC result using EDMA with FREERTOS running?

    No, we dont have free Rtos example for Control SS. I will check this in free Rtos and get back to you.

    What is the trigger to your DMA Read? Is it ADC EOC?

    adc_app_ISR triggerd by EOC

    Do you have two interrupts configured for the same ADC EOC?

    2) How to figure this issue out, where should I check to see if I miss something or everything is configured correctly?

    You can take the ADC DMA example as reference, and get it work on top of Free Rtos. And then work the other tasks configurations on top of it.

    I will also check from Free Rtos side at my end.

    3) Is it possible because of the conflict between several interrupts (adc_isr, dma_isr, RTI0) bringing the issue? Should I configure the priority of interrupts and how to make it through SysConfig?

    Yes for RTI timer interrupt priority, it can be set through syscfg.

    For other interrupts, you can use hwiPrms.priority parameter 

    Thanks & regards

    Sri Vidya

  • Hi Sri Vidya,

    Thanks a lot for your reply.

    Only one ADC interrupt ADC0 INT1 was enabled during the test.

    The trigger of DMA is ADC0_INT1 ( '''' dma_trig_xbar<-dma_xbar '''' )  in Syscfg.

    I'm looking forward to see your feedback regarding FREERTOS.

    Regards,

    Lync

  • Hi Lync

    I have performed basic porting of ADC DMA Continuous example on the task switch free Rtos example.

    I did this to check if free Rtos and DMA might have any issues. And as expected the code is working fine. Here is the example:

    Task_ADC_DMA.zip

    I have Grounded the ADC1 AIN0 channel to test the behavior and it is as expected.

    Also with 3.3V connected to ADC1 AIN0 channel.

    Thanks & Regards

    Sri Vidya

  • You can debug the issue by checking below configurations for ADC DMA:

    Initially check if the ADC DMA example that you have configured alone is working, without the timer interrupts (make the timer interrupts and other peripheral interrupts as lowest trigger priority - 15)

    1. check to see if the PWM --> triggering the ADC SOC in syscfg

    2. ADC EOC conversion interrupts need to be configured in the Syscfg

    3. These Interrupts are linked to DMA 

    Cross check the DMA Xbar, DMA Trigger and INT Xbar configurations.

    4. check the DMA intialisation code:

    5. Check the ADC EPWM Trigger Code

    Hope this helps.

    Regards

    Sri Vidya

  • Hi Sri Vidya,

    Thanks for your great support. I will come back to you follwoing your advice and and example.

    Regards,

    Lync

  • Hi Lync

    Sure, no problem. 

    Regards

    Sri Vidya

  • Hi Sri Vidya,

    I did similar modification on my side, and it did work as expected!

    Now I have new question:

    1)If I want to periodically trigger the DMA transfer and interrupt of transfer completion after EOC of ADC0, what should I do?  In the example adc_soc_continuous_dma, it looks the DMA transfer only performs once. 

    I removed the disable functions in isr, now the ADC can sample periodcally. I confirmed it through toggling an GPIO(B&) in App_adcISR. however, when I try to toggle the GPIO in App_dmach0ISR, it doesn't woke.

    After I added following codes to link the DMA params, still not work:

    EDMA_setPaRAM(baseAddr, param0, &edmaParam1);
    EDMA_setPaRAM(baseAddr, param1, &edmaParam2);
    EDMA_linkChannel(baseAddr, param0, param1);
    EDMA_linkChannel(baseAddr, param1, param1);

    task_switch_am263x-lp_r5fss0-0_freertos_ti-arm-clang.rar

    2) In App_dmach0ISR, should I do the clear handling to make this ISR available for next trigger likeI did in App_adcISR using ADC_clearInterruptStatus(), which API should I use to make it?

    Thanks for your great support!

    Regards,

    Lync

  • HI Lync

    Got it. I was able to reproduce the issue at my end.

    Will get back on this.

    Could you tell me which ADC interrupt are you clearing?

    clear handling to make this ISR available for next trigger likeI did in App_adcISR using ADC_clearInterruptStatus()

    software-dl.ti.com/.../EXAMPLES_DRIVERS_ADC_SOC_CONTINUOUS_DMA.html

    Regards

    Sri Vidya

  • Hi Sri Vidya,

    I used ADC_clearInterruptStatus(gAdc0baseAddr, ADC_INT_NUMBER1) to clear ADC0_INT1, which is used to trigger the App_adcISR() callback function.

    task_switch_am263x-lp_r5fss0-0_freertos_ti-arm-clang.rar You can also check adc_soc_continuous_dma.c file in previously attached project.

    Thanks a lot for your support.

    Regards,

    Lync

  • Hi Lync

    OK got it. Looking into it

    Thanks & Regards

    Sri Vidya

  • Hi Lync

    To perform recurring operations through DMA you will have to link the paRAM sets to itself. The example for EDMA through linking is already present in the SDK in this location:

    https://software-dl.ti.com/mcu-plus-sdk/esd/AM263X/latest/exports/docs/api_guide_am263x/EXAMPLES_DRIVERS_EDMA_LINK_TRANSFER.html

    You can use this as reference to modify your example.

    For more information, refer to the 11.2.3.3.7 Linking Transfers section in the TRM.

    In the Link Transfer EDMA example from the SDK, you can see the API for linking:

        EDMA_setPaRAM(baseAddr, param0, &edmaParam1);
        EDMA_setPaRAM(baseAddr, param1, &edmaParam2);

        EDMA_linkChannel(baseAddr, param0, param1);
     
    Regards
    Sri Vidya