Skip to content

ADC and DAC xxx_timed() methods can't be used concurrently #1129

Closed

Description

@ul5255

DAC.write_timed(..., mode=pyb.DAC.CIRCULAR) and ADC.read_timed(...)
can't be used concurrently. The call to ADC.read_timed() stops the signal
generated by DAC.write_timed(). For details see http://forum.micropython.org/viewtopic.php?f=3&t=550&start=10#p3159

Activity

  1. ul5255 commented on Feb 22, 2015

    @ul5255
    Author

    I'd suggest to allocate one timer to the ADC(s) and a separate timer to the DAC(s).

  2. dpgeorge commented on Feb 22, 2015

    @dpgeorge
    Member

    I'd suggest to allocate one timer to the ADC(s) and a separate timer to the DAC(s).

    Yes, that's a reasonable thing to do. Could even allow to pass a timer object in as a kwarg to select the timer, with default being tim6.

  3. peterhinch commented on Mar 6, 2015

    @peterhinch
    Contributor

    That has the advantage of generality: for example you might want to allocate a timer to each DAC instance to enable them to output asynchronously.

  4. ul5255 commented on Apr 27, 2015

    @ul5255
    Author

    Should I should go ahead and implement this? If yes: What is the proper way of doing that? I have another pull request (#1130) which is untouched since 22-FEB-2015 even though I thought I followed the instructions for pull requests. Implementing different timers for DAC and ADC is certainly more involved.

  5. dpgeorge commented on Apr 27, 2015

    @dpgeorge
    Member

    @ul5255 yes this is something you can try to implement. I didn't yet because it's difficult :) Especially since DMA restricts which timers work with which peripherals. And also I want to make ADC.read_timed work with DMA.

    Please feel free to start thinking/hacking on these ideas. Eg a good start is to simply list all the timers and DMA channels for DAC and ADC and see which ones work with each other.

  6. dpgeorge commented on Jul 21, 2015

    @dpgeorge
    Member

    DAC now allows you to specify a different timer for write_timed, so both ADC and DAC can work together (ADC still uses Timer(6) always).

    Would be nice to be able to specify timer for ADC similar to DAC, so leaving this issue open until that is implemented.

  7. bmentink commented on Jul 21, 2015

    @bmentink

    Can you also specify a different timer for each DAC channel? Is the current change checked in, I would like to try it.

  8. dpgeorge commented on Jul 21, 2015

    @dpgeorge
    Member
  9. dpgeorge commented on Jul 22, 2015

    @dpgeorge
    Member

    ADC.read_timed now allows to specify a timer to use for the triggering. For example:

    adc = pyb.ADC(pyb.Pin("X19"))
    buf = bytearray(100)
    tim = pyb.Timer(2, freq=100)
    adc.read_timed(buf, tim)

    You can use any timer to set the read frequency. You can then use a different timer (or even the same one if you want the same frequency) for DAC.write_timed.

  10. bmentink commented on Jul 22, 2015

    @bmentink

    Terrific! .... now all we need is DMA support for the Timer and it will be game-set-and-match ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions