T4.1 DMA lib issues

Status
Not open for further replies.

uuryuu

Member
Hello,

I have written code that uses adc0 and adc1 and store these values into 2 dma buffers, and then writes to SD card using Arduino IDE 1.8.15. It works for t3.5, and t3.6, but when I try to load onto t4.1 I've gotten alot of errors.I was able to fix a handful, but this current error has got me wanting to dive into datasheet and fix manually.....id prefer not to.

But issue is with DMAchannel.h. Heres code I'm having issues with and where error stops

error:dma2 - 'ADC0_RA' was not declared in this scope


Code:
#include <ADC.h>
#include <DMAChannel.h>
#include "array"
//#include <SdFat.h>
DMAChannel dma1;     // used to declare the dma.### object
DMAChannel dma2;     // used to declare the dma.### object




std::array<volatile uint16_t, (uint32_t)64 * 512> buffer __attribute__ ((aligned (16 * 1024)));      // size of buffer is limited due to the Teensy's program memory


ADC *adc = new ADC(); // adc object;           // used to declare the adc.### object

std::array<volatile uint16_t, (uint32_t)64 * 512> buffer1 __attribute__ ((aligned (16 * 1024)));
char str[128] ;
typeof(*dma1.TCD)  tcd_mem[4] __attribute__ ((aligned (32))) ;
typeof(*dma2.TCD)  tcd1_mem[4] __attribute__ ((aligned (32))) ;


void setup() {

adc->adc0->startSingleRead(MeasurementPin);

  adc->adc0->setAveraging(1); // set number of averages
  adc->adc0->setResolution(16);
  adc->adc0->setConversionSpeed ( ADC_CONVERSION_SPEED::HIGH_SPEED);

  adc->adc0->setSamplingSpeed   ( ADC_SAMPLING_SPEED:: VERY_LOW_SPEED  );

  adc->adc0->setReference(ADC_REFERENCE::REF_3V3);                //set ADC reference voltage
  dma2.source(ADC0_RA);
    dma2.transferSize(2);
  dma2.triggerAtHardwareEvent (DMAMUX_SOURCE_ADC0);


  /*----------------------------------------------------------------*/
  adc->adc1->startSingleRead(MeasurementPin2);

  adc->adc1->setAveraging(1); // set number of averages
  adc->adc1->setResolution(16);
  adc->adc1->setConversionSpeed ( ADC_CONVERSION_SPEED:: HIGH_SPEED);
  adc->adc1->setSamplingSpeed   ( ADC_SAMPLING_SPEED:: VERY_LOW_SPEED  );

  adc->adc1->setReference(ADC_REFERENCE::REF_3V3);                //set ADC reference voltage
  dma1.source (ADC1_RA);
  dma1.transferSize(2);
  dma1.triggerAtHardwareEvent (DMAMUX_SOURCE_ADC1);

}



Has anyone else has issues with dmachannel.h and t4.1?
 
Have you tried the DMA examples that are part of the ADC library.

I know that we had/have it working.

Note: The registers and the like for the T4.x are completely different than for the Then for the T3.x... Things like the names of the two ADC modules on the boards.
Likewise what DMAMUX settings .

Good luck
 
Have you tried the DMA examples that are part of the ADC library.

I know that we had/have it working.

Note: The registers and the like for the T4.x are completely different than for the Then for the T3.x... Things like the names of the two ADC modules on the boards.
Likewise what DMAMUX settings .

Good luck

Thanks for reply.

But yes I have tried using the DMAexamples and they compile.....But I need to dive into what everything is actually doing in the examples,Or I just look up what registers that need to be written to....such is life
 
Status
Not open for further replies.
Back
Top