Forum Rule: Always post complete source code & details to reproduce any issue!
Page 6 of 6 FirstFirst ... 4 5 6
Results 126 to 129 of 129

Thread: Teensy 4.0 which pins for which ADC

  1. #126
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,755
    T3.x adc.startPDB converting to T4 and shared resources:

    @mjs513, @defragster, @manitou and @Paul - and others...

    Will soon look at merging the ADCL_t4 stuff into ADC library... But first want to play some with how to translate the ADC library code that does Analog reads at a specific frequency:
    like my well monitoring stuff sets up DMA on both ADC channels (T3.6) and I have an interval timer setup that gets N samples at a rate of 3000 times per second... So at each interval I do something like:

    Code:
      _adc0_busy = true;
      _adc1_busy = true;
      _adc0_dma.enable();
      _adc1_dma.enable();
      adc->enableDMA(ADC_0);
      adc->enableDMA(ADC_1);
      _adc0_dma.enable();
      _adc1_dma.enable();
      adc->adc0->startPDB(60 * 50);
      adc->adc1->startPDB(60 * 50);
    Luckily @manitou has examples of parts of this for T4, from me to start from (Thanks!) and again I have mentioned parts of this earlier in thread.
    for now ignore DMA... The example timed sketch sets up

    ADC1 to use hardware trigger with channel 16 (which maps to ADC_ETC)

    ADC_ETC0 is setup with -1 chain and trigger 0 and ...

    XBAR is setup as glue that says map PIT trigger 0 to ADC_ETC (XBARA1_IN_PIT_TRIGGER0, XBARA1_OUT_ADC_ETC_TRIG00)

    Then PIT0 is setup to run at the speed we desire...

    (Clear as MUD) Which for my own simple code I can hopefully reasonably easy hack. But more fun will be how to make it such that it works well with other libraries and system code...

    Example which timer to use? Example used PIT0, which the system(library) code IntervalTimer uses and sets it's own ISR handler and when you do a begin (for the first time per object) it finds the first free channel of which there are only 4... Could either try to use IntervalTimer code or simply make sure to check/mark the channels. (TCTRL != 0) so that they don't grab same resource.

    Should we instead try different timer? QTIMER? which most can be used by PWM, not sure if some of the unused ones could be used, i.e. can they be initialized in a way that does not interfere with PWM
    (example I dont think any of QTIMER4 is used, nor 1-3, or 2-1, 2-2, 2-3?
    QT4-2 looks like it can optionally used on pin 9...

    ADC_ETC: how to choose the different trigger? i.e. should I just pick a specific one for ADC1 and another one for ADC2?

    XBAR: I think this sort of takes care of itself, that is you use the register number in it of the OUTPUT Number/2 (either top or bottom half) and value is the input number, so as long as we can pick the proper timer and proper ADC_ETC then no conflict...

    But again the more interesting question is how to manage usage of some of the system resources, like Timers, like ADC_ETC Channels (might be more interesting later with touch screen stuff (TSC) I think I would need to read that chapter a few more times (maybe 10)...

    I have same question about other resources like FlexIO... In my flexIO library I have some classes to try to manage the timers, shifters, ... But that only works if you use my library...

    Well now back to contemplating...

  2. #127
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,335
    Up to about 5 times on ADC_ETC but now have decided to go back to reading the ADC chapter as well now that I looked at ADC_ETC and @manitou's code at the same time - now you know why I have a headache.

    Timer: Think you may want to avoid interval timer, a lot of other libraries use that as well and could cause conflicts. QTIMER/PIT might be better choices.

    XBAR: Yeah. Once you decide on the timer the rest is relatively easy - that is to configure XBAR.

    ADC_ETC: Besides the timers supposedly ADC_ETC has the ability to use a software trigger. Haven't been able that to work yet - missing something - probably because I have no idea what I am doing. ADC_ETC has seems has lots of channels/input options. To make life simpler may want fix the pairs for ADC_ETC, A0/A1, A2/A3 etc. May have to something similar to what you did in the FlexIO library for ADC_ETC if we can figure it out.

    Ok back to other diversions.....

  3. #128
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,755
    @mjs513 - Yep but issue is IntervalTimer is PIT timer, so could do similar code to try to grab one of them.

    I might be missing something, but I see we have GPT, PIT, and Quad Timer as three different timers... Not sure about GPT - but I don't see any XBAR input values...

  4. #129
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,335
    @KurtE

    Just looked myself and concur, didn't see XBAR for GPT. Didn't see anything in the manual either, at least that I could find.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •