Changing DUE prescaler

Hello fellow Arduino enthusiasts!

I've been working on a project that reads data from 4 analog inputs, and pairs this with location and time data from a gps, and stores this to an SD card, while also using the gps speed info to control a motor.

Despite the relatively powerful processor on the DUE, the program only loops at about 2Hz.
I need a bare minimum of 5Hz, and ideally 10 or 20.

I read that the prescaler on the DUE is 512, presumably to save power?
I'd like to significantly reduce this, but I don't know how.

Has anyone experimented with changing the prescaler? I know it has been done for the ATmega based boards.

Other suggestions for improving the loop speed would also be greatly appreciated!
So far I have set the gps baud rate to 115200, and gps data is stored in variables so multiple queries per loop don't occur.

Thanks
Liam

What prescaler are you talking about?

The Due runs at 84MHz, that's the chips design maximum IIRC.

Without being able to see you code the only way I can suggest to speed it up
is for you to write it better!

Yes, reading 4 analogs, requesting GPS data and writing data to SD card with a timestamp and controlling a motor based on GPS data hardly sounds like it would raise a sweat for the DUE, even a lowly AVR should handle this without a problem.

Maybe you have a few delay(..) hiding in your code that need to be removed.
Maybe you are doing unnecessary looping.
Maybe you are blocking your code while waiting for response data from some device such as the GPS.

Like MarkT infers, maybe your code could be written better, but are not able tell as we can't see it.


Paul

  REG_ADC_CR = 0x02; //start ADC conversion
  REG_ADC_CHER = (1 << 7); //enable A0
  REG_ADC_MR = (REG_ADC_MR & ~(0x01 <<  4L)) | (0x01 <<  4L); //0 = 12 bits, 1 = 10 bits
  /*Disable for your purposes*/REG_ADC_MR = (REG_ADC_MR & ~(0x01 <<  7L)) | (0x01 <<  7L); //1 = enable freerun mode, 0 = disable
  REG_ADC_MR = (REG_ADC_MR & ~(0xff <<  8L)) | (0x00 <<  8L); //prescaler = MCK / ( (PRESCAL+1) * 2 )
  REG_ADC_MR = (REG_ADC_MR & ~(0x0f << 16L)) | (0x00 << 16L); //startupTime set to 0
  REG_ADC_MR = (REG_ADC_MR & ~(0x03 << 20L)) | (0x00 << 20L); //analogSettlingTime set to 0
  REG_ADC_MR = (REG_ADC_MR & ~(0x03 << 28L)) | (0x00 << 28L); //transferPeriod set to 0

Check the datasheet is you don’t understand where I go this information. Its around page mid 1300s