Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 11 of 11

Thread: T4 ADC Library V0

Threaded View

  1. #1
    Junior Member
    Join Date
    Dec 2018
    Location
    PNW
    Posts
    14

    T4 ADC Library V0

    There is more work to be done, but it seems to be functional, so I figured I would release what I have so far.

    These files are a transcription of Pedvide's ADC library to the T4. My goal was to keep as much of the code from the T3 functional with the T4 as I could. So many of the examples from the T3 library work with little to no modification, but some things don't makes as much sense as they should. To use these files, replace the ones currently in the ADC library folder of the Teensy with these. Also, you need to move the RingBufferDMA.cpp and .h files out of the folder since I haven't gotten to those yet and the complier complains about them. The whole thing seems to work alright, but I have not done extensive testing across the board yet so if you run into bugs/issues, let me know.

    I have used this to learn a lot more about the Teensy's and the ADC's in general, it has been a great learning experience for me, but my code leaves a lot to be desired. If anyone wants to improve upon it please do.

    If anyone has questions, just drop them here. Hopefully these are of use to some people.

    Some notes:

    The T4 has no differential pins so if you try to use them, it will just throw a 'wrong-pin' error.

    T4 only has 12 bits of resolution, higher selections default to 12.

    While the T4 names the adc's 1 and 2, the code will still call them 0 and 1 to match the T3 convention.

    I have not reworked the DMA ring-buffer files, so those ones don't work yet

    For my "PDB", I used Qtimer 4 and buried the ISR in the .cpp file so you no longer need to write a seperate pdb_isr to clear the interrupt.

    The Qtimer currently still software triggers the ADC instead of Hardware triggering it. It's on my list to change, but I haven't gotten there yet.

    I have limited ability to test the frequency stability of my PDB, but cursory testing seems to match about right. I would greatly appreciate if someone could test the stability for me (it accepts frequencies from 20 - 75000000, but clearly won't work anywhere near the higher end).

    I have been able to transfer 1.2-1.6 MSPS across the USB with my PDB so far, If I get to hardware triggering I imagine it will go higher.

    If you are using only one ADC with the PDB, you may get an "adc1_isr definition error". Just add a dummy isr function somewhere in your code, eg: void adc1_isr(){}

    TODO:

    Merge this code back with Pedvide's so a single library handles all Teensy's
    Create an 'Atomic.h' for T4 so it behaves better, rewrite code to match
    Swtich the "PDB" to hardware triggering, look at using second timer so that each ADC can use different frequency
    rewrite the DMA ring buffer to add T4.
    Fix any bugs people find.
    Attached Files Attached Files

Posting Permissions

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