DAC driver for STM32 *almost* done

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

Moderator: RoccoMarco

User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

DAC driver for STM32 *almost* done

Post by Giovanni »

Hi,

I finally merged the DAC driver code in 3.0, the driver has been modified in order to support the dual mode (but the dual mode is not yet complete). The timer code has been removed from the driver so it is much simpler, the triggering can be done with the GPT, PWM and ICU drivers, this opens to interesting combinations.

I also plan to add a simple API to write a value on the DAC manually when the driver is in "ready" state.

Those interested could give it a try and help with debug. So far there is a demo for the F4 only.

Giovanni
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 STM32 *almost* done

Post by Giovanni »

Direct write and dual mode implemented, demo for dual mode added.

The driver needs testing, waiting for feedback :)

Giovanni
neums
Posts: 137
Joined: Fri May 08, 2015 1:09 pm
Has thanked: 10 times
Been thanked: 5 times

Re: DAC driver for STM32 *almost* done

Post by neums »

Hello,
can you provide a running example project for the DAC driver?

Thanks. :-)
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 STM32 *almost* done

Post by Giovanni »

Hi,

There are two demos under /testhal/STM32/STM32F4xx/DAC. The driver is still experimental, not much tested.

Giovanni
rew
Posts: 383
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 14 times

Re: DAC driver for STM32 *almost* done

Post by rew »

Giovanni, Great work. I'm a short on time right now, but I'm looking forward to testing this!

Plan:
* First test on STM32F4.
* Then test on STM32F072.

Is it expected to work on '072, or are you aware of essential differences?
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 STM32 *almost* done

Post by Giovanni »

It should work on all platforms but I tried on F3 and F4 only, let me know if there are difficulties.

It is derived by the contributed DAC driver but I decided to move the triggering outside the driver, there is no need to limit it to one timer.

Giovanni
erfan
Posts: 14
Joined: Sat Apr 18, 2015 4:25 pm

Re: DAC driver for STM32 *almost* done

Post by erfan »

hi, I just tried DAC test. it was awesome. great work :D

can you tell me how to increase DAC frequency? Is there any documentation regarding DAC configuration? I want to generate 600KHz waveform.

Thanks,
rew
Posts: 383
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 14 times

Re: DAC driver for STM32 *almost* done

Post by rew »

Ran into a small bug in the main chibios stuff. Whether it's related to the problems I'm seeing I don't know yet....

http://prive.bitwizard.nl/dma_redir_patch.diff

UPDATE: DAC seems to work on stm32F072....
I'm using the direct output function:

Code: Select all

    dacPutChannelX (&DACD1, 0, t);
    t += 300;
    if (t > 0xfff) t -= 0x1000;
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 STM32 *almost* done

Post by Giovanni »

erfan wrote:can you tell me how to increase DAC frequency? Is there any documentation regarding DAC configuration? I want to generate 600KHz waveform.


Hi,

You have to program the GPT, the DAC is synchronized with that.

Giovanni
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 STM32 *almost* done

Post by Giovanni »

rew wrote:Ran into a small bug in the main chibios stuff. Whether it's related to the problems I'm seeing I don't know yet....

http://prive.bitwizard.nl/dma_redir_patch.diff

UPDATE: DAC seems to work on stm32F072....
I'm using the direct output function:

Code: Select all

    dacPutChannelX (&DACD1, 0, t);
    t += 300;
    if (t > 0xfff) t -= 0x1000;


Hi,

That bug was in the new code, thanks for the patch, committed.

Giovanni
Post Reply