DAC driver for the STM32

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

chelox
Posts: 17
Joined: Tue Jan 22, 2013 8:24 pm

Re: DAC driver for the STM32

Post by chelox »

hello!

Very good job!

I wanted to use the driver for the DAC.
I was watching the example of STM32F4-LCD-DSP is in https://github.com/mobyfab/ChibiOS-Examples

How I can add it to Chibios?
Chibios What version do you use?
Should apply a patch?

Thank you!
User avatar
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 the STM32

Post by Giovanni »

Hi,

I plan to integrate the driver in the 3.0 branch first, please continue working with it, when the time will come I will post here. Integration in 2.6 should be possible too.

Giovanni
sebx86
Posts: 14
Joined: Sat Aug 10, 2013 9:57 pm

Re: DAC driver for the STM32

Post by sebx86 »

Can we assume DAC output buffer will always be circular ?
User avatar
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 the STM32

Post by Giovanni »

sebx86 wrote:Can we assume DAC output buffer will always be circular ?


The driver specifies both a linear and circular buffer mode, implementations are expected to support both.

Giovanni
sebx86
Posts: 14
Joined: Sat Aug 10, 2013 9:57 pm

Re: DAC driver for the STM32

Post by sebx86 »

OK, I'll do this :)
mobyfab
Posts: 484
Joined: Sat Nov 19, 2011 6:47 pm
Has thanked: 21 times
Been thanked: 31 times

Re: DAC driver for the STM32

Post by mobyfab »

I updated the dac-new branch, it is now based on the current master.
It complies with your dac files definitions.

There are testhal examples for F0 and L1. I'll redo the others later.

I compiles and runs but is untested as I don't have a scope right now.

https://github.com/mobyfab/ChibiOS/tree/dac-new

Giovanni, when this is done and tested I can make a patch for inclusion.
beaming
Posts: 11
Joined: Sun Nov 10, 2013 9:27 pm

Re: DAC driver for the STM32

Post by beaming »

Great job Mobyfab!

I just compiled and ran testhal/STM32L1xx/DAC. According to digital multimeter it works, I will check it with a scope on Monday.

Giovanni, is it along ChibiOS lines to have a code which just sets a DAC output to a particular value, i.e. not a waveform? This is often handy in a slow loop applications.
User avatar
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 the STM32

Post by Giovanni »

Such a function could be easily added to the API but you don't even need a driver for that :)

Giovanni
beaming
Posts: 11
Joined: Sun Nov 10, 2013 9:27 pm

Re: DAC driver for the STM32

Post by beaming »

Well, it is as trivial as to send a word to a register at least in some cases, though care should be taken to stop relevant DMA and probably free timers if they used before. But it is hardware dependent, which ruins the idea of a general API. If you specify how function call should look like, I will try to forge the function body at least for one architecture. Since, I am likely to use it for my projects, I am volunteering.
User avatar
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 the STM32

Post by Giovanni »

There is no need to stop anything, design the function to be called only when a streaming operation is not in progress, see the driver state machine. You may also create a low-level only function and don't case about portability.

About the DAC driver, it is not going to be integrated yet so any of the current features may change.

Giovanni
Post Reply