Show Posts
Pages: [1]
1  Products / Arduino Due / Re: DAC support on: April 30, 2013, 02:59:08 pm
Hi Guys,

Is it possible to change the DAC resolution using the dacc_write_conversion_data(DACC_INTERFACE, value);?
It's always using 12 bits, even if I change using that command: analogWriteResolution(smiley-cool;.
Is it seem the analogWriteResolution(smiley-cool; only works when we write a value using analogWrite(DAC0, value);

Thanks
2  Products / Arduino Due / Re: Timer Interrupts on Due on: April 11, 2013, 08:20:28 pm
Hey guys,

I am trying to get the timer interrupt works. I used your library, also I tried using without library, but
if I set the frequency for 200kHz, I always get a waveform on oscilloscope with the half frequency, so 100kHz.
Is that right? I couldn't get 1MHz as someone said in a post before, the maximum was 585kHz, when I set the frequency for 2MHz.

Someone can help me?

Thanks

Code:
//Chirp wave output

//#include <DueTimer.h>

#define TAM 4095

int frequency = 1000000;
volatile int i = 0;

void waveGenerate(){
  dacc_write_conversion_data(DACC_INTERFACE, (i=!i)*4095);
  //dacc_write_conversion_data(DACC_INTERFACE, sinWave[i++]);
  //if(i==4096)
  //  i=0;
}

void setup(){
  Serial.begin(9600);
  pinMode(DAC0, OUTPUT);
  analogWriteResolution(12);
  pmc_enable_periph_clk(DACC_INTERFACE_ID);
  dacc_reset(DACC_INTERFACE);
  dacc_set_transfer_mode(DACC_INTERFACE, 0);
  dacc_set_power_save(DACC_INTERFACE, 0, 1); //Sleep mode = 0 (Normal Mode), Fast Wake Up = 1 (Enabled)
  dacc_set_timing(DACC_INTERFACE, 0x0, 1, 0x0); //REFRESH 0x0, MAXS = 1 (Max Speed Mode Enabled), STARTUP = 0 (0 periods of DACClock)
  
  dacc_set_writeprotect(DACC_INTERFACE, 0); //Disable
  dacc_set_analog_control(DACC_INTERFACE, DACC_ACR_IBCTLCH0(0x02) |
                   DACC_ACR_IBCTLCH1(0x02) |
                   DACC_ACR_IBCTLDACCORE(0x01));
  dacc_disable_trigger(DACC_INTERFACE);
  dacc_set_channel_selection(DACC_INTERFACE, 0);
  dacc_enable_channel(DACC_INTERFACE, 0);
  

  Timer4.attachInterrupt(waveGenerate).setFrequency(frequency).start();
}

void loop(){

}

Pages: [1]