Sign Up

Unlock the Gateway: Join the Embed Threads

Have an account? Sign In

Captcha Click on image to update the captcha.

Have an account? Sign In Now

Sign In

Unlock the Possibilities: Dive In with Login Access

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Embed Threads

Embed Threads

Embed Threads Navigation

    • Blogs
    • Forum
    • About Us
    • Contact Us
    • Books
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Forum
  • Communities
  • Questions
    • New Questions
    • Must Read Questions
    • Trending Questions
    • Hot Questions
  • Polls
  • Groups
  • Add group
  • Badges
  • Users
  • Help
  • Blogs
  • Forum
  • About Us
  • Contact Us
  • Books
Kunaal
  • 1
KunaalBeginner
Asked: August 6, 20232023-08-06T06:01:49+00:00 2023-08-06T06:01:49+00:00In: Embedded Software Development

Multi-channel continuous DMA Conversions

  • 1

Hi. I’m working on a project and I require to use multiple ADC Channels for continuous conversions using DMA. I am writing the conversion callback, I am unable to find a way to identify which channel has triggered the callback, I want to use conditional statements to perform different tasks for different channels callbacks.

adcdmastm32stm32 adcstm32 dmastm32 hal
  • 3 3 Answers
  • 518 Views
  • 0 Followers
  • 0
Share
  • Facebook
    Leave an answer

    Leave an answer
    Cancel reply

    Browse
    Captcha Click on image to update the captcha.

    3 Answers

    • Voted
    • Oldest
    • Recent
    1. alokm014 Enlightened
      2023-08-11T13:25:58+00:00Added an answer on August 11, 2023 at 1:25 pm
      This answer was edited.

      In a multi-channel ADC setup with continuous conversions using DMA, you’ll need to determine which ADC channel triggered the DMA callback in order to perform different tasks for each channel. To achieve this, you can follow these steps:

      1. Configure ADC Channels: Set up your ADC to scan through multiple channels in continuous mode. Configure the ADC and DMA peripherals according to your microcontroller’s specifications. Each channel should generate an interrupt after a conversion is completed.

      2. Configure DMA: Set up the DMA controller to handle the ADC data transfers. Make sure to enable the circular buffer mode so that DMA continues fetching data indefinitely.

      3. DMA Callback Function: This function will be called by the DMA controller whenever a DMA transfer is complete. Since you are performing continuous conversions, this callback will be triggered after each complete scan of all the ADC channels.

      4. Channel Identification: To identify which channel has triggered the callback, you can use a few methods:

      a. Use ADC’s Current Channel Register: Many microcontrollers have a register that stores the current active channel. In the DMA callback, you can read this register to determine the current channel. Then, you can use conditional statements to perform different tasks based on the active channel.

      b. Use DMA Transfer Counter: DMA controllers often have a transfer counter that indicates how many transfers have been completed. Since you’re performing a scan of multiple channels, you can calculate the active channel based on the transfer count and the total number of channels.

      5. Conditional Statements: Once you’ve identified the active channel, you can use conditional statements to execute specific tasks based on the channel. For example:

      void DMA_ADC_Callback(void) {
      // Identify the active channel using the methods described above
      uint8_t activeChannel = …; // Determine the active channel here

      // Perform tasks based on the active channel
      if (activeChannel == CHANNEL_0) {
      // Task for channel 0
      } else if (activeChannel == CHANNEL_1) {
      // Task for channel 1
      } else if (activeChannel == CHANNEL_2) {
      // Task for channel 2
      }
      // Add more conditions for other channels as needed
      }
      `

      By utilizing the methods mentioned above, you can accurately identify the channel that triggered the DMA callback and execute the appropriate tasks for each channel. Make sure to consult your microcontroller’s documentation for specific register names and details regarding DMA and ADC configuration.

      • 0
      • Reply
      • Share
        Share
        • Share onFacebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    2. Ritesh236 Explainer
      2023-08-06T10:41:02+00:00Added an answer on August 6, 2023 at 10:41 am

      Hello Kunnal,

      Would you please provide few more details regarding issue which you are facing at your end?

      1. which controller are you using?
      2. what is the ADC resolution you are using?
      3. callback details and triggering mechanism.

      Regards,
      Ritesh Prajapati

      • 0
      • Reply
      • Share
        Share
        • Share onFacebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
      • Kunaal Beginner
        2023-08-06T16:59:18+00:00Replied to answer on August 6, 2023 at 4:59 pm

        Hi,
        Thanks in advance for helping me out, sir.

        I am using the STM32 with 12-bit ADCs. The callback basically stores the values in different variables and is triggered on completion of the ADC Conversion.

        • 0
        • Reply
        • Share
          Share
          • Share onFacebook
          • Share on Twitter
          • Share on LinkedIn
          • Share on WhatsApp

    Sidebar

    Ask A Question

    Stats

    • Questions 85
    • Answers 373
    • Best Answers 15
    • Users 800

    Free PDF Downloads

    A Roadmap to a Successful Career

    HTTP, WS and TLS: The Complete Guide

    Embedded Interview Questions

    • Popular
    • Answers
    • alokm014

      Embedded System Testing: Strategies and Approaches

      • 162 Answers
    • Paresh

      USB Serial Port giving junk data

      • 20 Answers
    • Shubha V

      Why can't we save the footprints in kicad and How ...

      • 14 Answers
    • D Sai krishna

      Error in final launch sequence

      • 7 Answers
    • Jagadesh

      SD card data logging

      • 7 Answers
    • como Fazer tcc
      como Fazer tcc added an answer Very soon this web site will be famous amid all… May 20, 2025 at 5:11 pm
    • About
      About added an answer If you are going for finest contents lke me, just… May 20, 2025 at 4:27 pm
    • https://www.Tumblr.com/quillofthephoenix/782693432006230016/phoenix-writing-services-where-your-writing?source=share
      https://www.Tumblr.com/quillofthephoenix/782693432006230016/phoenix-writing-services-where-your-writing?source=share added an answer Appreciate thee recommendation. Let me try it out. https://www.Tumblr.com/quillofthephoenix/782693432006230016/phoenix-writing-services-where-your-writing?source=share May 20, 2025 at 1:00 pm
    • How to write admission essay
      How to write admission essay added an answer Wow, that's what I was searching for, what a material!… May 20, 2025 at 12:40 pm
    • como fazer TCC
      como fazer TCC added an answer Woah! I'm really diggijg the template/theme of this blog. It's… May 20, 2025 at 12:40 pm

    Explore

    • Forum
    • Communities
    • Questions
      • New Questions
      • Must Read Questions
      • Trending Questions
      • Hot Questions
    • Polls
    • Groups
    • Add group
    • Badges
    • Users
    • Help

    Footer

    Embed Threads

    Embed Threads

    Join us on a transformative journey where knowledge is amplified and solutions are empowered.

    About Us

    • Blogs
    • Forum
    • About Us
    • Contact Us
    • Books

    Legal Stuffs

    • Privacy Policy
    • Adsense Disclaimer

    Help

    • Help
    • Contact Us

    Follow

    © 2024 Embed Threads. All Rights Reserved
    With Love by Embed Threads.