Hello fellow avr people!
I'm working on a project which involves 8 digital trigger pins (on PORTC) and 8 analog pins on PORTA. I want to use the xmega event system to trigger a DMA ADC transfer on the corresponding pin on PORTA when a pin on PORTC goes hi. At the end of the DMA transfert, an ISR strobe the corresponding pin on PORTF for 1ms and the process is complete. In memory, I have an array of 8 values of the ADC result according to the proper pin on PORTA which I use for timed processes to create animations on LED strips.
As of now in my project, I use the ADC directly in the main loopand try to get a peak value. This is working, but not precise enough to my taste and seems a waste of CPU so I changed my circuit to use a schmitt trigger on PORTC so that the ADC on PORTA is done only when needed. Lastly, the reset pin on PORTF is connected to a transistor which drains the capacitor that helps holding the transient for a good measure on PORTA's external circuitry.
First off, does all this makes sense from the microntroller's event and DMA perspective?
Second, should I route the pins to individual event channel or is there a way to route them all in the same event channel?
I noted that the DMA can only be triggered from event channel 0, 1 and 2. So this setup will probably not work with the DMA:
EVSYS.CH0MUX = EVSYS_CHMUX_PORTC_PIN0_gc; EVSYS.CH1MUX = EVSYS_CHMUX_PORTC_PIN1_gc; EVSYS.CH2MUX = EVSYS_CHMUX_PORTC_PIN2_gc; EVSYS.CH3MUX = EVSYS_CHMUX_PORTC_PIN3_gc; EVSYS.CH4MUX = EVSYS_CHMUX_PORTC_PIN4_gc; EVSYS.CH5MUX = EVSYS_CHMUX_PORTC_PIN5_gc; EVSYS.CH6MUX = EVSYS_CHMUX_PORTC_PIN6_gc; EVSYS.CH7MUX = EVSYS_CHMUX_PORTC_PIN7_gc;
Here is a quick sequence diagram of what I expect to happen in the end:
I know I can do this all using interrupts but the CPU is already running lots of other stuff for animations calculations, so if this can be done using the event system and DMA, that'd be a huge improvement on my current design.
Thanks for any feedbacks :)