I made two new timer setup functions with different divider settings. One that works down to 10Hz and one that is more accurate at higher frequencies that I will use later in my program as I will be using 40kHz. Seems to work. Maybe someone finds...
I had set the divide in the timer incorrectly. I can get down to 18Hz with the highest divider.
Here is the output now which seems more appropriate considering the frequency is set to 20Hz.
Values:
2255, 2246, 2020, 2240, 2243, 2021, 2236...
If I disable the timer the ISR is not triggered again and neither are the ADC's (keep printing the same value). I guess it's the timer. I have to look into setting the timer properly. I had chatGPT do it for me, probably why it's not working...
Well you know how to disable the timer:
TMR4_ENBL &= ~(1 << 0); // Disable Timer
So if you do that in the ADC_ETC IRQ handler, does it retrigger?
If it doesn't: you know the IRQ is being cleared correctly, it's just recurring constantly because...
Hmmm... I could trigger the ADC_ETC from software. However I'd have to spend several days to figure out how to do that. I have never done this stuff and just getting this far took 3 weeks.
I have this:
// Debug output to verify timer setup
Serial.printf("Timer started with calculated period: %lu ticks\n", (uint32_t)(F_BUS_ACTUAL / (frequency * 2)));
Serial.flush();
It prints: Timer started with calculated period...
I would start by checking how frequently the timer is triggering.
The quad timers only have 16-bit comparison registers, you're probably going to need to chain two of them together for low frequencies.
(Optionally, connect the xbar to an IO pin...
If I write this in the ISR function:
IMXRT_ADC_ETC.TRIG[0].CTRL = ADC_ETC_DONE0_1_IRQ_TRIG_DONE0(0);
Then it only interrupts once as it should but then it never interrupts again. This was a mistake but it stops it.
In the manual there are the DONE0_1_IRQ registers. Those are sending the interrupt I believe. Those need to be reset I think.
In the imxrt.h file there is this:
IRQ_ADC_ETC0 = 118,
IRQ_ADC_ETC1 = 119,
IRQ_ADC_ETC2 =...
@PaulStoffregen What I'm suspecting is that the settings for interrupts in the ADC_ETC have some kind of continuous signal for the interrupt and that the ISR is resetting it but it keeps firing or something like that. But I haven't been able to...
Oh sorry, I was using DMA before but couldn't get it to work so I repurposed the isr function but forgot to change the name of it. It does no difference though.
Here is a new version with the ISR function name updated...
Thanks for the reply. So could the constant interrupting actually be the serial print acting up because it's inside an isr? I could maye toggle the built in led. Thanks for the tip about the priority. I've never used interrupts, I just copied...
Best not to do prints from an ISR. That will invoke USB activity that is at a raised priority - and can cause collisions with other output elsewhere. Perhaps use a pin for Toggle on entry/exit.
If the _isr() were set at a higher priority then no...
Hello!
I've set up ADC_ETC to read 10 sensors in a sequence and I'm having trouble with the interrupt I'm trying to use to move the sensor data after ADC_ETC completes. Can anyone see what's going on? I'm using the Done0 interrupt and I think...
There are more errors. I think it's a data alignment issue. I'm reading 16 bits at a time and moving to the next 16 bit but perhaps it needs to be read 32 bits at a time. Right now I'm trying to write the buffer address with the TCD into a...
Damn, it seems to read all ten values correctly but for some reason I'm getting the same values over and over from the sensors so it seems something is not updating correctly.
Ok, here is a version that works completely autonomously in the background without interrupts and this should work to read up to 16 sensors at the same time. Uses eDMA features to switch between the three buffers and keep a variable to indicate...
This seems to work. I used a third buffer, this ensures that it's impossible to access a buffer that is currently being overwritten unless you access it and linger on it for more than the time it takes to read all sensors in worst case, and twice...
I’m already swapping buffers with interrupts. I have two buffers but the problem is what if I’m reading from the buffer just before it’s about to switch the flag?
I think there is a function to prevent those scenarios but I have to find it...
This library doesn't seem to work in PlatformIO. I tried both their library manager way to install and just manually copying the library into my project. Any plans to make it work there?
@KurtE I managed to get this working sort of. This has been a nightmare. Here is my code. I implemented two ADC_ETC chains of length 5 and put adc 1 on trig 0 and adc 2 on trig 4. Used sync mode so that I can trigger adc 1 and adc 2 will follow...
Yes, I'm trying to figure it out. It seems to do what I want. The only thing is it's up to 8 pins so I would have to add an extra trig chain with chain length of 2. But I haveto get the first chain to work first.
IMXRT_ADC_ETC.TRIG[0].CHAIN_1_0...
I assume you looked back at the main ADC forum thread, that talked about some of this a few years ago.
Like some of the posts near:
https://forum.pjrc.com/index.php?threads/adc-library-with-support-for-teensy-4-3-x-and-lc.25532/page-21#post-292852
Thanks. Never heard of NXPXpresso but found this: https://github.com/nxp-mcuxpresso/mcux-sdk-examples/tree/main/evkbmimxrt1060/driver_examples/adc_etc/adc_etc_hardware_trigger_conv
It seems to have some examples, thanks I will see what I can find.
It seems doable if you know what you are doing which I don’t: Set up the ADC_ETC to trigger a chain of ADC conversions. Synchronised mode, first chain is 8 long and select back to back conversions. Second chain is 2 long. ADC must be set to...
I'm pulling my hair with this. It seems like it would be very simple to do but I just can't figure it out.
Can someone run this code and see if they can help me figure out why the ADC is not being triggered by the ADC_ETC?
#include <Arduino.h>...
You are more helpful than you realise. I will look through the library you linked to. Thank you.
It seems the ADC_ETC is not executing properly in my code, it’s supposed to set a flag when it’s triggering the ADC which it doesn’t.
I found this...
Ok that was completely wrong, here is a simple test to start converting with the ADC_ETC with just a single chain and print out the result register. It sets up but I'm getting zero's from the sensors.
I'm not sure if the pin mappings are correct...
I've been doing some research and here is my setup so far for the ADC_ETC to chain 10 ADC conversions and use DMA to write them to memory. I have not tested this yet, was thinking to use a timer to trigger these chains. I'm assuming that the...
Sorry it has been a very long time since I did anything with the ADC code. You might be able to do something like that
using DMA and maybe chaining the ADC reads to each other... I do not remember any of the details, but I believe
that some of...
I've tried to get stuff working with chatGPT but haven't been successful. I would like to be able to get all 10 sensors read once and then I should be able to do work on those 10 readings when they are available. I need minimal latency. Of course...
Hello!
What is the preferred method to read all 10 analog sensors on a teensy 4 continuously while allowing for the loop to run without any waiting for the ADC's?
I've been doing this which allows for processing on the previous sensor pair...