Hi there, I am in trouble now and very need help in hurry.
Output from DAC is so slow about 2Hz sinewave no delay is added.
I agree to have silent gap between complete sine cycle for computational task.
However, I want 33Hz or 337 Hz (if possible) sine wave.
void setup() {
AdcBooster();
Serial.begin(9600);
analogWriteResolution(10);
analogReadResolution(12);
analogReference(AR_EXTERNAL);
}
void loop() {
int AA1[512];
int AA2[512];
int AA3[512];
int AA4[512];
int valueout;
int count =0;
for (int i=0; i<=2047; i=i+4){
valueout=512+(int)512*sin((float)i*3.14159/1024);
analogWrite(A0, valueout);
AA1[count]=analogRead(A1);
AA2[count]=analogRead(A2);
AA3[count]=analogRead(A3);
AA4[count]=analogRead(A4);
count=count+1;
}
}
My system is running good with nano 33 BLE.
However, it damaged and has not come yet.
I have to use MKR ZERO. yes it more lower noise and has DAC.
Very compact for my application.
I know ADC is slow so I use booster code from this forum
speeding up analogread() at the Arduino Zero - Hardware / Arduino Zero - Arduino Forum
void AdcBooster()
{
ADC->CTRLA.bit.ENABLE = 0; // Disable ADC
while( ADC->STATUS.bit.SYNCBUSY == 1 ); // Wait for synchronization
ADC->CTRLB.reg = ADC_CTRLB_PRESCALER_DIV32 | // Divide Clock by 64.
ADC_CTRLB_RESSEL_12BIT; // Result on 12 bits
ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_1 | // 1 sample
ADC_AVGCTRL_ADJRES(0x00ul); // Adjusting result by 0
ADC->SAMPCTRL.reg = 0x00; // Sampling Time Length = 0
ADC->CTRLA.bit.ENABLE = 1; // Enable ADC
while( ADC->STATUS.bit.SYNCBUSY == 1 ); // Wait for synchronization
}
Thank you in advance,
E.M.