That should be taken from the datasheet/reference manual, it is limited by HW.
Giovanni
DAC driver for STM32 *almost* done
Moderator: RoccoMarco
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: DAC driver for STM32 *almost* done
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.
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
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
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: DAC driver for STM32 *almost* done
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
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
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
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
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times