Page 2 of 3
Re: DAC driver for STM32 *almost* done
Posted: Sun May 31, 2015 12:26 pm
by rew
I wanted to have DAC and USB working on the '072, so I was trying to figure out what was going wrong. Nothing helped.
Then suddenly my computer dies. Won't turn on either. Turns out my STM'072 board was lying on the bare shield of an USB cable... Computer broken? PCB broken? Nope. Removing the short, computer boots, board works, USB-serial works!
Re: DAC driver for STM32 *almost* done
Posted: Mon Jun 01, 2015 5:11 pm
by mobyfab
Awesome, I did not have much time to take care of it.
Thanks!
Re: DAC driver for STM32 *almost* done
Posted: Mon Jun 01, 2015 5:16 pm
by Giovanni
mobyfab wrote:Awesome, I did not have much time to take care of it.
Thanks!
Don't mention it, thanks for the implementation.
Re: DAC driver for STM32 *almost* done
Posted: Tue Jun 02, 2015 8:34 am
by rew
Let me say that I find the "convert this value now" function very useful.
Many people will not require the advanced features with DMA etc. When updating say less than 1000x per second, that way of doing it will be good enough. And with a bit of luck this frees up a DMA channel that could be used for something else.
Similarly, I think the ADCs should have a "convert and give me the value now" function. I'll implement it when I have the time and contribute the code, but In the mean time I would like you to know about this "request", so that if it's easy and you happen to be "messing" in that area of code.... maybe....
(If it's already there, I couldn't find it last time I looked)
Re: DAC driver for STM32 *almost* done
Posted: Tue Jun 02, 2015 9:07 am
by Giovanni
Hi,
I considered such a function for the ADC but it is not so simple, the ADC requires parameters: channel, sample time, resolution etc. If you pass all of those then you have a special case of adcConvert.
Giovanni
Re: DAC driver for STM32 *almost* done
Posted: Sat Jun 06, 2015 11:27 am
by rew
I would like to call:
Code: Select all
value = adc_convert_once (ADCD1, ADC_CHAN1, 0);
The "0" is the "options" parameter where I can pass defines that make it deviate from the defaults. The shortest sample-time is probably too short in a significant number of cases, but a few notches up should be fine in many cases.
I sell a product that offers ADC conversion of an input. I've defined the device report the raw value, 10 bits, in the public interface.
Switching to STM32 inside gives me a problem: Either I throw away two valid bits, or I have to redefine the interface.
This would mean that a platform independent interface is a good idea. "The returned value is in the range 0-65535. Depending on the hardware currently the bottom 4-6 bits do not contain valid information. Future hardware might be equipped with a better AD converter." (on the other hand, ADC_O_OVERSAMPLE_256 would give you statistical valid results in the bottom 4 bits).
So, what you're saying is that what I'm proposing is a thin layer above adcConvert.
Code: Select all
adc_sample_t adcConvertOnce (ADCDriver *adcp, int chno, int options)
{
ADCConversionGroup cgrp;
adcsample_t samples[1];
cgrp.circular = 0;
cgrp.num_channels = 1;
cgrp.end_cb = NULL;
cgrp.error_cb = NULL;
// The channel number comes back in one of these registers,
// The options (in the future?) too.
cgrp.cr1 = ...
cgrp.cr2 = ...
cgrp.smpr1 = ...
cgrp.smpr2 = ...
cgrp.sqr1 = ...
cgrp.sqr2 = ...
cgrp.sqr3 = ...
adcConvert (adcp, &cgrp, samples, 1);
return samples[0];
}
(this is based on the documentation for "adcConvert" that I found using google. )
What I'm after is that porting a simple: "get the voltage at a pin" from one member of the STM32 family to another, or from STM32 to AVR or LPC becomes simple.
Re: DAC driver for STM32 *almost* done
Posted: Thu Jun 11, 2015 4:29 am
by DeusExMachina
I know that there is a demo for STM32F072-Disco in Chibios v.3.0
But stable branch is 2.6.x.
How about back-porting this demo and 72 support to 2.6.x branch?
Re: DAC driver for STM32 *almost* done
Posted: Thu Jun 11, 2015 8:02 am
by Giovanni
DeusExMachina wrote:I know that there is a demo for STM32F072-Disco in Chibios v.3.0
But stable branch is 2.6.x.
How about back-porting this demo and 72 support to 2.6.x branch?
The 2.6.x branch uses old CMSIS headers from ST, 072 is not supported by those headers. Porting the new headers to 2.6.x would mean re-doing some of the work already done in the 3.0 HAL, possibly introducing issues in doing so.
Are there problems switching to 3.0? it will be released as stable very soon now.
Giovanni
Re: DAC driver for STM32 *almost* done
Posted: Fri Jun 12, 2015 5:18 am
by DeusExMachina
Legacy code, is the most obvious reason
BTW, it seems that RTOS F051 demo is working correct on stm32F072, and UART/i2c drivers are also functional.
Re: DAC driver for STM32 *almost* done
Posted: Sat Jul 18, 2015 9:22 pm
by iman
Hi
I want to know that what is the highest frequency for GPT in order to use it for DAC driver on STM32F3?