Page 3 of 3
Re: DAC driver for STM32 *almost* done
Posted: Sat Jul 18, 2015 10:10 pm
by Giovanni
That should be taken from the datasheet/reference manual, it is limited by HW.
Giovanni
Re: DAC driver for STM32 *almost* done
Posted: Wed Oct 14, 2015 7:42 pm
by erfan
Hi,
I didn't know where to ask my question. So please excuse me if this is irrelevant to the topic.
I'm working on STM32F4-Discovery. My purpose is to digitize an analog signal by using ADC driver, then process the imported signal and after that generate the result by using DAC driver. At first, I neglect the processing part and I just try to generate the imported signal by using the DAC driver. I used the following code.
Code: Select all
int main(void) {
halInit();
chSysInit();
palSetPadMode(GPIOC, 3, PAL_MODE_INPUT_ANALOG);
adcStart(&ADCD1, NULL);
adcStartConversion(&ADCD1, &adcgrpcfg2, samples2, ADC_GRP2_BUF_DEPTH);
palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_ANALOG);
dacStart(&DACD1, &dac1cfg1);
gptStart(&GPTD6, &gpt6cfg1);
dacStartConversion(&DACD1, &dacgrpcfg1, samples2, sizeof(samples2));
gptStartContinuous(&GPTD6, 2U);
while (true) {
if (palReadPad(GPIOA, GPIOA_BUTTON)) {
gptStopTimer(&GPTD6);
dacStopConversion(&DACD1);
}
}
return 0;
}
Although you can poorly see the primary analog signal in the oscilloscope, but it's all noisy. In addition for example when I change the primary signal frequency or cut it down, the output signal doesn't follow the changes. It seems that DAC driver isn't following or generating the ADC buffer online. Would someone tell me that is this possible to do such a work? Because in DAC example provided in testhal, DAC driver just generate a static buffer. Your help would be greatly appreciated.
Thanks
Re: DAC driver for STM32 *almost* done
Posted: Wed Oct 14, 2015 8:07 pm
by Giovanni
Frankly I never tried both ADC and DAC on the same buffer triggered by the same timer.
The noise could depend on DMA priorities, try giving ADC a greater priority than DAC, just an idea.
Giovanni
Re: DAC driver for STM32 *almost* done
Posted: Fri Oct 16, 2015 4:07 pm
by erfan
Hi again,
First I want to thank you for your prompt reply. I think I asked my question in the wrong way
according to the testhal examples, the DAC driver generate constant buffer. Now, consider that I want to generate a variable buffer which its components are not defined previously. Is it possible to generate a variable signal by using the DAC driver? I'm working on STM32F4.
Thank you very much
Re: DAC driver for STM32 *almost* done
Posted: Fri Oct 16, 2015 4:10 pm
by Giovanni
It is possible, just don't declare it "const".
Giovanni